【发布时间】:2014-09-22 18:48:47
【问题描述】:
当我的程序第一次进入while(!looking) 循环时,它会执行任务,但之后它不会继续获取单词并翻译它们。需要一些帮助来弄清楚为什么它没有运行。
while (cin.good()){
getline(cin, lines);
while (!looking) {
spot = lines.find(" ");
if (spot == -1){
looking = true;
spot = lines.length( );
}
line = lines.substr(0, spot);
TP1stLetter(line);
if (!looking)
lines = lines.substr(spot + 1, lines.length( ) - spot + 1);
}
cout << endl;
//while( cin.good() ) {
//getline (cin, line);
//for(x = 0; x < line.size(); x++) {
//char letter = line[x];
//if (letter == 'a' || letter == 'e' || letter == 'i'
// || letter == 'o' || letter == 'u'){
//cout << letter;
//}
//}
}
}
【问题讨论】:
-
你试过逐行调试吗?
-
您希望我们“解析”您的整个工具吗?
-
您似乎没有将
looking重置为 false -
@Desolator 我不确定你的意思?
-
@John 只是意味着您的程序非常庞大,需要询问。您最好只询问其中不起作用的部分。
标签: c++ loops while-loop