C/C++ 难题困境 #20

admin 2022年6月27日01:09:54评论31 views字数 320阅读1分4秒阅读模式

问题:

下面这段代码会可能会产生什么问题?

#include #include using namespace std;int main(){    ifstream infile;    infile.open("test.txt",ios::binary);    char buffer[10];    while(!infile.eof()){        infile.getline(buffer,sizeof(buffer),'n');        cout<<buffer<<endl</buffer<<;    }    return 0;}

上面代码中,文件内容如下:

this is a test

this is a test too!

this is the third test!

C/C++ 难题困境 #20


原文始发于微信公众号(汇编语言):C/C++ 难题困境 #20

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年6月27日01:09:54
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   C/C++ 难题困境 #20http://cn-sec.com/archives/1145222.html

发表评论

匿名网友 填写信息