询问者
find()返回0

常规讨论
-
strcpy(seekchar,"9");
cout<<seekchar<<endl;
strcpy(replacechar,"______________________");
seeklength = seekword.length();
while(!inout.eof())
{
inout.getline(buffer,200);
sourcefile.append(buffer);
sourcefile.append("\r\n");
}
cout<<seekchar<<endl;
int index=0;
bool mark=true;
int iu=1;
while(mark)
{
index = sourcefile.find(seekword);
iu++;
cout<<index<<endl;
cout<<string::npos<<endl;
cout<<"iu"<<iu<<endl;
system("pause");
if(iu>6)
{mark=false;}
if(index == string::npos)
{
cout << "Didn't find the word or replace the word is OK!" << endl;
mark=false;
}
else
sourcefile.replace(index,seeklength,replaceword);
cout<<seekchar<<endl;
}- 已编辑 Honny_yeyh 2012年9月19日 7:32
- 已更改类型 Damon ZhengModerator 2012年9月26日 2:42
全部回复
-
您好,
从目前您给的代码来看,最后一个循环不可能是死循环。
iu变量每进行一次循环就自加1,当ui大于6时就会退出循环。所以这个循环最多执行7次。
请检查一下,看看代码是不是发错了或者是有其他问题。
谢谢。
Damon Zheng [MSFT]
MSDN Community Support | Feedback to us
-
您好,
由于您目前所给的代码不能重现问题,我暂时将这个帖子的类型改为“常规讨论”。
谢谢您的理解和支持!
Damon Zheng [MSFT]
MSDN Community Support | Feedback to us