注册 登录
编程论坛 C++教室

1到3处代码的意思不清楚

墨香555 发布于 2011-09-14 18:11, 282 次点击
1到3处的代码在程序中是什么意思啊,谁能帮我解释下
int main()
{
    using namespace std;
    char input[Arsize];
    char next;
    cout<<"enter a line: \n";
    cin.get(input,Arsize);
    while(cin)                                       
    {
        cin.get(next);                              1
        while(next!='\n')                           2
            cin.get(next);                          3
        strcount(input);
        cout<<"enter next line(empty line to quit): \n";
        cin.get(input,Arsize);
    }
    cout<<"Bye\n";
    return 0;
}
3 回复
#2
xg56992011-09-15 00:23
1:cin 是全局对象       调用本身自己类中的get函数,你传递了一个next就调用带一个参数的get函数,该函数作用是将输入的字符保存在next变量中,同时返回该对象
2:当输入的字符中不等于换行符(既回车)
3:继续调用1
#3
lucky5635912011-09-15 08:15
代码写的真差
#4
刘杰明2011-09-15 08:43
        cin.get(next);   
因为你上面定义next了,所以在你标注的第一句话中是将字符保存在了next当中。
        while(next!='\n')                           2
            cin.get(next);                          3
就是while判断啦,如果不回车的话就将next的值继续调用
1