C++读取文件出现问题

三次元齐次方程组 2013-12-25 02:19:08
#include<iostream>
#include <FSTREAM>
using namespace std;

void main()
{

fstream tt;
tt.open("aaa.dat",ios::in);
if (tt.fail())
{
cout<<"aaa";
}
unsigned __int64 aa;
int i=0;
while(true)
{
i++;
tt.read((char*)(&aa),sizeof(__int64));
if(tt.eof())
{
cout<<i<<endl;
// printf("%d",aa);
break;
}

}


}

文件有48字节 值读取了前两个就完了

" 氢C?2.氢C?2.氢C?2.氢C?2.氢C?2.//文件内容
...全文
367 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
wsw8473871 2014-01-08
  • 打赏
  • 举报
回复
if (tt.fail()) { cout<<"aaa"; return;//文件打开失败,记得退出 } if(!tt.eof())//你本意是这样吧 { cout<<i<<endl; printf("%d",aa); } else{ break; } tt.close();//记得close文件

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧