首页 > 编程语言 > 详细

c++输入格式问题

时间:2017-09-16 23:50:55      阅读:289      评论:0      收藏:0      [点我收藏+]

1、输入字符串

有两种形式,一种是:

string s;
cin>>s;

另一种是:

char s[10];
scanf("%s",s);
循环输入时
char s[3][10];
for(int i=0;i<3;i++){
    scanf("%s",s+i);
}

2、获取一行内容

string s;
while(getline(cin,s)){}
注意:在cin后getline之前要执行cin.ignore()

 

c++输入格式问题

原文:http://www.cnblogs.com/coderht/p/7533393.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!