为什么我的代码在vs2013中不能编译
#include<stdio.h>int my_cp(const char *src_file, const char *dest_file)
{
FILE *in_file, *out_file;
in_file = fopen(src_file, "rb");
if (in_file == NULL)
{
return 1;
}
out_file = fopen(dest_file, "wb");
if (out_file == NULL)
{
return 2;
}
char rec[256];
size_t bytes_in, bytes_out;
while ((bytes_in = fread(rec, 1, 256, in_file)) > 0)
{
bytes_out = fwrite(rec, 1, bytes_in, out_file);
if (bytes_in != bytes_out)
{
return 3;
}
}
fclose(in_file);
fclose(out_file);
return 0;
}
int main()
{
int result;
if (result = my_cp("d:\\temp\\1.txt", "\\temp\\2.txt") != 0)
{
switch (result)
{
case 1:
printf("打开源文件出错!\n");
break;
case 2:
printf("打开目标文件出错!\n");
break;
case 3:
printf("拷贝文件出错!\n");
break;
default:
printf("发生未知错误!\n");
break;
}
};
printf("ok!\n");
}错误 1 error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. c:\users\think\documents\visual studio 2013\projects\win32project1\win32project1\源.cpp 5 1 Win32Project1
[此贴子已经被作者于2016-2-14 20:09编辑过]