首页 > 其他 > 详细

getline和get的区别

时间:2014-09-03 18:03:57      阅读:294      评论:0      收藏:0      [点我收藏+]
#include<iostream>
#include<fstream>
#include<cstring>
using namespace std;

int main()
{
    ifstream file("1.txt");
    char ch[20];
    cout<<"getline: "<<endl;
    while(file.getline(ch,1000000,\n))
        cout<<ch<<endl;
    //get调用之后只会显示一行,因为get不会丢弃流中的换行符
    cout<<"get:"<<endl;
    while(file.get(ch,1000000,\n))
        cout<<ch<<endl;
}

 

getline和get的区别

原文:http://www.cnblogs.com/wuchanming/p/3954248.html

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