问题:
下面这段代码会可能会产生什么问题?
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
- 左青龙
- 微信扫一扫
- 右白虎
- 微信扫一扫
评论