没编译肯定没有
修改一下项目配置
#include "stdafx.h"
#include "stdio.h"
#include <stdlib.h>
void pula()
{
FILE *fp;
FILE *fp1;
//判断是否打开文件
if ( (fp = fopen("c:\\123.exe", "rb")) == NULL )
puts("Fail to open file!");
//或者文件大小
fseek(fp,0,2);
int z = ftell(fp);
//申请内存空间
char* date = (char*)malloc(z);
if(date == NULL)
puts("申请失败");
//让指针回到开头位置
fseek(fp,0,0);
//写入内存中
for(int i = 0; i<z;i++)
{
fscanf(fp, "%c", (date+i));
printf("写入内存成功\n");
}
//判断打开文件如果文件不存在就创建一个叫1111.exe的文件
if ( (fp1 = fopen("c:\\1111.exe", "wb")) == NULL )
puts("Fail to open file!");
//写入数据
for(i=0;i<z;i++)
{
fprintf(fp1,"%c",*(date+i));
printf("写入文件成功\n");
}
free(date);//释放内存空间
fclose(fp1);//操作结束后关闭文件
fclose(fp);//操作结束后关闭文件
}
int main()
{
pula();
return 0;
}
这段代码编译没成功,看下面的错误提示查找问题。