【发布时间】:2015-09-24 03:59:46
【问题描述】:
我正在尝试从具有以下内容的文件中读取字符串:
r FFFF
r FF
r FFFF
这是我的代码:
int main ()
{ int a; ifstream ifile;
ifile.open("hi.txt");
while (!ifile.eof())
{
ifile.getline(data, 100); // read a line from file
a = strlen(data);
cout<<'length"<<a;
}
}
我得到了意想不到的输出:length7length5length6。
我做错了什么?
【问题讨论】:
标签: c++ file-handling strlen file-read