C++ 如何找到子字符串的位置并从中打印它
到目前为止,我有这个C++ 如何找到子字符串的位置并从中打印它,c++,string,C++,String,到目前为止,我有这个 if(tempString.find(mString) != string::npos) //if found word { cout<<endl<<tempString<<endl; //this prints the entire line } if(tempString.find(mString)!=string::npos)//if-find-word { 不能使用: size\t pos=tempString.fin
if(tempString.find(mString) != string::npos) //if found word
{
cout<<endl<<tempString<<endl; //this prints the entire line
}
if(tempString.find(mString)!=string::npos)//if-find-word
{
不能使用:
size\t pos=tempString.find(mString);
if(pos!=字符串::npos)
{
std::string to_print=tempString.substr(pos);
库特
size_t pos = tempString.find(mString);
if (pos != string::npos)
{
std::string to_print = tempString.substr(pos);
cout << to_print;
}