#include <fstream>
#include <cstring>
#include <iostream>
using namespace std;
void test(char name [])
{ ofstream fout;
fout.open("2.jpg",ios::out|ios::binary);
ifstream fin;
fin.open("1.jpg",ios::in|ios::binary);
char content[4];
while(!fin.eof())
{fin.read(content,4);
cout<<fin.gcount()<<endl;
fout.write(content,fin.gcount());
}
//fout<<name;
fout.write(name,strlen(name));
fout.close();
}
int main ()
{
char name []="周zms12.457";
test(name);
return 0;
}
fstream 默认以字符方式读取和写文件,除非设置ios::binary
最新推荐文章于 2021-05-23 14:19:41 发布