您的位置:首页 > 编程语言 > C语言/C++

c++初学者(首先请大神解释个问题,不大明白)

2014-04-09 08:40 225 查看
#include<iostream>

int main()

{

using namespace std;

char ch;

int count=0;

cout<<"Enter characters;enter # to quit;"<<endl;

cin>>ch;

// cin.get();

while(ch!='#')

{

cout<<ch;

++count;

cin>>ch;

// cin.get();

}

cout<<endl<<count<<" characters read"<<endl;

// cin.get();

// cin.get();

return 0;

}

在while循环中的cin输入语句起到什么作用,另外,在VS2010中,这个程序无法捕捉画面,运行结果一闪即逝,我加了cin.get()也没用,还请大神帮帮忙

1:cin是C++中字符读取的函数,在未遇到最后一个字符的时候,cin返回的都是true,如果遇到了结束,则返回的是false

2:字符串指针数组:

const char * cities[5]={"asd","sds","sds","www","fff"};

char数组

char maxtemps[2]={"sdsd","ddddd"};

string对象数组

const string cities[3]={"sada","dfdsf","gfgr"};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐