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

#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"};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值