| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1700 人关注过本帖
标题:这是个什么格式个getline(cin,s[i])
只看楼主 加入收藏
げ訾澐み
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2007-7-18
收藏
 问题点数:0 回复次数:3 
这是个什么格式个getline(cin,s[i])
getline(cin,s[i])是什么意思
他和cin.getlines([i])一样吗
还有顺便帮我解释下cin.getlines()我只知道他是输入一个字符串,就我的理解是输入字符串遇到“\n"的时候就停止对吗 ?
搜索更多相关主题的帖子: cin getline 格式 字符 输入 
2007-07-20 16:37
maoguoqing
Rank: 6Rank: 6
来 自:重庆
等 级:贵宾
威 望:28
帖 子:2980
专家分:19
注 册:2005-12-5
收藏
得分:0 
getline(cin,s[i]);就是读入一个字符串保存在s[i]中,s[i]肯定是string类型的
cin.getlines([i]);是cin.getline,而且没有你这种表达形式,自己看看msdn,默认情况下遇到'\n'
停止,但是你可以通过第三个参数进行设置。。

天行健,君子以自强不息!!QQ:68660681
2007-07-20 22:12
一番宝瓶
Rank: 1
等 级:新手上路
帖 子:239
专家分:0
注 册:2007-7-14
收藏
得分:0 
多看看msdn

getline(cin,s[i]);
-------------------------------------------------------------------
Syntax:
  istream& getline( istream& is, string& s, char delimiter = '\n' );

The C++ string class defines the global function getline() to read strings from and I/O stream. The getline() function, which is not part of the string class, reads a line from is and stores it into s. If a character delimiter is specified, then getline() will use delimiter to decide when to stop reading data.

For example, the following code reads a line of text from STDIN and displays it to STDOUT:

 string s;
 getline( cin, s );
 cout << "You entered " << s << endl;
-----------------------------------------------------------------
cin.getline(str[i]);
-----------------------------------------------------------------

Syntax:
  istream& getline( char* buffer, streamsize num );
  istream& getline( char* buffer, streamsize num, char delim );

The getline() function is used with input streams, and reads characters into buffer until either:

  • num - 1 characters have been read,
  • a newline is encountered,
  • an EOF is encountered,
  • or, optionally, until the character delim is read. The delim character is not put into buffer.
    ------------------------------------------------------------



2.3.2.2.2.0
2007-07-20 22:27
野比
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:1627
专家分:516
注 册:2007-5-24
收藏
得分:0 

现在看msdn都没时间了... 完全靠臆断...


女侠,约吗?
2007-07-21 00:18
快速回复:这是个什么格式个getline(cin,s[i])
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015432 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved