#include<fstream.h>
#include<conio.h>
#include<alloc.h>
class profile
{
public: char *copyBytes;
}p;
void main()
{
unsigned int size;
fstream file ("file.mp3", ios::binary | ios::in | ios::out);
fstream copy ("copy.mp3", ios::binary | ios::in | ios::out);
file.seekg(0, ios::end);
size=file.tellg();
file.seekg(0);
while(!file.eof())
{
p.copyBytes=(char*)malloc(size);
file.read((char*)p.copyBytes, size);
copy.write((char*)p.copyBytes, size);
free(p.copyBytes);
}
file.close();
}
该程序会复制二进制文件 file.mp3。原始二进制文件 (file.mp3) 为 2.13 MB,复制文件 (copy.mp3) 为 2.14 MB。为什么?