我的程序无法正常运行,因此我想知道是否可以使用\\t
在C ++文本中使用find()
查找选项卡。
string str ="line1\tline2";
int k = str.find('\t');
if(k > 0)
cout<<"yes\n";
else
cout<<"No\n";
you can use find('\\t')
Formal :
#include <iostream> // std::cout
#include <string> // std::string
int main ()
{
std::string str="This\tTab";
char tab = '\t';
std::size_t found = str.find(tab);
if (found!=std::string::npos)
std::cout << "Tab found at: " << found << '\n';
return 0;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.