Std::find编译失败



如果我在代码中使用std::find,我的项目无法构建。我得到的错误如下

usr/include/c++/4.6/bits/stl_algorithm .h:162:4: error: no match for ' operator== ' in ' _first._gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* with _Iterator = char*, _Container = std::basic_string, __gnu_cxx::__normal_iterator<_Container>::reference = char&= = __val '/usr/include/c + +/4.6/位/stl_algo.h: 162:4:注意:候选人:

下面是我的代码…

        std::string lValueCmd = "";
        std::string lModeType = "";
        std::string lAPModeCmd = "sudo iwconfig /sbin/wlan0 | grep -i 'Mode:' | awk '{print $1}'";
      // function to retrive values from linux command and store it in lValueCmd
      lResult =    RequestCmdOutput( lAPModeCmd, lValueCmd )      ; // function to retrive values from linux command and store it in lValue Cmdd
     // std::cout << " the string is " << lValueCmd << std::endl;// debug
      std::string delimiter= ":";
      std::string::iterator pos;
      pos= std::find( lValueCmd.begin(), lValueCmd.end(), delimiter); // no error if I comment this line.

头文件,我使用的是iostream, algorithm和string .

您需要搜索单个字符,因为"'"是一个以空结束的字符串,因此由字符'组成,并且您当前的分隔符是std::stringstd::find将比较字符串中的元素,这些元素本身都是单个字符:

char delimiter= ':';

相关内容

  • 没有找到相关文章

最新更新