void main()
{
fstream f;
f.open("c.bil",ios::in);
if(!f){
cout<<"c.bil不能打开";
return;
}
fstream f2;
f2.open("b.bil",ios::out|ios::trunc);
if(!f2)
{
cout<<"b.bil不能创建 /n";
f.close();
return;
}
int i=0;
while(1)
{
char ch;
int d=0;
f.read(&ch,1);
if(f.eof())
break;
i++;
f2.write(&ch,1);
}
cout<<i;
f.close();
f2.close();
}
c文件中的内容为01 0A 01 01 01 01 01 01 01 01 01 01 01 01 01 01
为什么写到B文件里数据变为 01 0D 0A 01 01 01 01 01 01 01 01 01 01 01 01 01 01
请高人指点迷津
本文展示了一个使用C++进行文件读写的示例程序。该程序将一个特定格式的文件内容从c.bil复制到b.bil,并在过程中记录了字符数量。讨论了在文件内容转换过程中出现的特殊字符变化原因。
1492

被折叠的 条评论
为什么被折叠?



