| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1169 人关注过本帖
标题:本菜鸟一直对getline 有点不懂
只看楼主 加入收藏
asd6791868
Rank: 1
来 自:逆流
等 级:新手上路
帖 子:362
专家分:7
注 册:2008-7-27
结帖率:88.24%
收藏
 问题点数:0 回复次数:5 
本菜鸟一直对getline 有点不懂
哪位达人能举一个简单而且易懂的例子给我!~


谢谢拉
搜索更多相关主题的帖子: getline 
2008-12-13 14:43
PcrazyC
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:5652
专家分:0
注 册:2006-10-20
收藏
得分:0 
MSDN

The getline member function is similar to the get function. Both functions allow a third argument that specifies the terminating character for input. The default value is the newline character. Both functions reserve one character for the required terminating character. However, get leaves the terminating character in the stream and getline removes the terminating character.

The following example specifies a terminating character for the input stream:

#include <iostream.h>

void main()
{
   char line[100];
   cout << " Type a line terminated by 't'" << endl;
   cin.getline( line, 100, 't' );
   cout << line;
}

雁无留踪之意,水无取影之心
2008-12-14 15:17
PcrazyC
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:5652
专家分:0
注 册:2006-10-20
收藏
得分:0 
输入一行字符,以T结尾

比如输入2342DFEFTEFEFEF

LINE的结果就是前面的2342DFEF,遇到T就结束

雁无留踪之意,水无取影之心
2008-12-14 15:19
asd6791868
Rank: 1
来 自:逆流
等 级:新手上路
帖 子:362
专家分:7
注 册:2008-7-27
收藏
得分:0 
了解  
谢谢了

─條路 :  ┈片天  ┈個人  ─瞬間:
2008-12-14 16:03
快速回复:本菜鸟一直对getline 有点不懂
数据加载中...
 
   



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

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