编译器调用std库函数的原型?

时间:2016-10-25 15:41:37

标签: c++ string iostream getline

所以这是我的代码到目前为止......

    #include <iostream>
    #include <fstream>                
    #include <string>

            using namespace std;    
            int run_t = 0;
            char q_mos;

            class Destroyer_of_Worlds{
            public:
            string i_nput;
            string i_nput2;

            }lard;


int main () { //main executable


cout << "Would you like to write to the temporary datapcku database?\nSelect Y/N\n";

cin >>  q_mos;


if(q_mos == 'Y'){//phase one


    while(run_t==0){
    cout << "Running Input Operations.\n";

    //recieve input
    cout << "Please provide me with a Question so it can be achrived in the Active DB(Directory)\n";
    getline(cin, lard.i_nput);
    getline(cin, lard.i_nput);
    cout << "Recieved " << lard.i_nput << "at console line\n";

    //recieve input
    cout << "Please tell me the answer...\n";
    getline(cin, lard.i_nput2);
    cout << "Recieved " << lard.i_nput2 << "at console line\n";

    //terminate while loop        
    run_t=1;
    }





    } else {

    run_t=1;
    cout << "Booting into main operations...\n";


    }

cout << "At diagnostic Boot menu, prepare for diagnostic on system config         orginaztional routines.\n";
ofstream binlib;
binlib.open ("datapcku.bin", ios::app | ios::binary );
binlib << "Writing this to a file.\n";
binlib.close();
while(1){}
return 0;


}

但是如果你注意到第(34)行,你可以看到我重申了getline(cin,lard.i_nput);两次。在测试此代码时,它会跳过getline的第一个实例并提示我输入我的回答&#39;从第二个。很快我意识到我可以通过在我的程序完成其预期任务所需的第一个之前实现一个额外的getline函数调用来通过它。有没有人知道如何调试它?

0 个答案:

没有答案