Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/150.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 程序不';t连续循环_C++_Loops_While Loop - Fatal编程技术网

C++ 程序不';t连续循环

C++ 程序不';t连续循环,c++,loops,while-loop,C++,Loops,While Loop,当我的程序第一次进入while(!looking)循环时,它会执行任务,但之后它不会继续提取单词并翻译它们。需要一些帮助来找出它为什么不能通过 while (cin.good()){ getline(cin, lines); while (!looking) { spot = lines.find(" "); if (spot == -1){ looking = true; spot = lin

当我的程序第一次进入
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;
        //}
    //}
    }
 }
while(cin.good()){
getline(cin,line);
一边(!看){
spot=行。查找(“”);
如果(点==-1){
看=真;
spot=lines.length();
}
直线=直线。substr(0,点);
TP1stLetter(线路);
如果(!看)
lines=lines.substr(spot+1,lines.length()-spot+1);
}

我想不出两件事,希望能有所帮助 -您是否应该在while(!looking)循环的任何一点上设置looking=false? -是否在命令行中的参数字符串周围添加引号 这样地
YourExe.Exe这些词是五个参数

但是,您需要引号来生成字符串
YourExe.Exe“这是一个参数”

只需在
cout
语句后添加一行代码,如下所示:

if (mode == TOPIG) {
cout << "TOPIG MODE" << endl;
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;
    looking = false;

    //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;
    //}
    //}
  }
}
if(模式==TOPIG){

你能试着逐行调试它吗?你希望我们“解析”吗您的整个工具?看起来您没有重置
查看
false@Desolator我不知道你的意思是什么?@John只是说你的程序非常庞大。你最好只问其中不起作用的部分。争论的焦点是确定topig或frompig,但在topig上工作;我希望与cin.good和getlines合作,我可以连续要求翻译台词。你的意思是“应该”还是“不应该”?