16,551
社区成员
发帖
与我相关
我的任务
分享 CFile file("D:\\Windows XP 关机.rar",CFile::modeRead|CFile::typeBinary);
char* pBuf = new char[file.GetLength()];
int len = file.GetLength();
file.Read(pBuf,file.GetLength());
file.Close();
struct FILE_INFO
{
char* spBuf;
};//定义一个结构体
FILE_INFO finfo;
CFile nfile("C:\\Windows XP 关机.rar",CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
finfo.spBuf = new char[len];//为结构体的一个成员初始化
strcpy(finfo.spBuf,pBuf);//将原先读取的pBuf赋值给结构体的成员spBuf;
if(strcmp(finfo.spBuf,pBuf) == 0)//比较两个是否相同(我得出的结果是相同)
{
MessageBox("xiang deng");
}
nfile.Write(finfo.spBuf,len);//将数据写入文件中
nfile.Close();
return;