c(7) :warning C4996:'gets':This function or variable may b vc2008#include#includemain(){FILE *fp;char str[81],name[10];gets(name);if((fp=fopen(name,"w"))==NULL){printf("can not open\n");exit(0);}gets(name);fputs(str,fp);flose(fp);if((fp=fopen(name,"r
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/23 12:57:39
![c(7) :warning C4996:'gets':This function or variable may b vc2008#include#includemain(){FILE *fp;char str[81],name[10];gets(name);if((fp=fopen(name,](/uploads/image/z/12548888-8-8.jpg?t=c%287%29+%3Awarning+C4996%3A%27gets%27%3AThis+function+or+variable+may+b+vc2008%23include%23includemain%28%29%7BFILE+%2Afp%3Bchar+str%5B81%5D%2Cname%5B10%5D%3Bgets%28name%29%3Bif%28%28fp%3Dfopen%28name%2C%22w%22%29%29%3D%3DNULL%29%7Bprintf%28%22can+not+open%5Cn%22%29%3Bexit%280%29%3B%7Dgets%28name%29%3Bfputs%28str%2Cfp%29%3Bflose%28fp%29%3Bif%28%28fp%3Dfopen%28name%2C%22r)
c(7) :warning C4996:'gets':This function or variable may b vc2008#include#includemain(){FILE *fp;char str[81],name[10];gets(name);if((fp=fopen(name,"w"))==NULL){printf("can not open\n");exit(0);}gets(name);fputs(str,fp);flose(fp);if((fp=fopen(name,"r
c(7) :warning C4996:'gets':This function or variable may b vc2008
#include
#include
main()
{
FILE *fp;
char str[81],name[10];
gets(name);
if((fp=fopen(name,"w"))==NULL)
{
printf("can not open\n");
exit(0);
}
gets(name);
fputs(str,fp);
flose(fp);
if((fp=fopen(name,"r"))==NULL)
{
printf("canfhhkjadf\n");
exit(0);
}
fgets(str,strlen(str)+1,fp);
printf("oiehjhsdhfkjdf\n");
puts(str);
fclose(fp);
}
1>d:\my documents\visual studio 2008\projects\们渴望你的\们渴望你的\了房间.c(7) :warning C4996:'gets':This function or variable may be unsafe.Consider using gets_s instead.To disable deprecation,use _CRT_SECURE_NO_WARNINGS.See online help for details.
1> d:\program files\vc\include\stdio.h(279) :参见“gets”的声明
1>d:\my documents\visual studio 2008\projects\们渴望你的\们渴望你的\了房间.c(8) :warning 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.
1> d:\program files\vc\include\stdio.h(237) :参见“fopen”的声明
1>d:\my documents\visual studio 2008\projects\们渴望你的\们渴望你的\了房间.c(13) :warning C4996:'gets':This function or variable may be unsafe.Consider using gets_s instead.To disable deprecation,use _CRT_SECURE_NO_WARNINGS.See online help for details.
1> d:\program files\vc\include\stdio.h(279) :参见“gets”的声明
1>d:\my documents\visual studio 2008\projects\们渴望你的\们渴望你的\了房间.c(15) :warning C4013:“flose”未定义;假设外部返回 int
1>d:\my documents\visual studio 2008\projects\们渴望你的\们渴望你的\了房间.c(16) :warning 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.
1> d:\program files\vc\include\stdio.h(237) :参见“fopen”的声明
1>d:\my documents\visual studio 2008\projects\们渴望你的\们渴望你的\了房间.c(21) :warning C4013:“strlen”未定义;假设外部返回 int
1>正在链接...
1>了房间.obj :error LNK2019:无法解析的外部符号 _flose,该符号在函数 _main 中被引用
1>d:\My Documents\Visual Studio 2008\Projects\们渴望你的\Debug\们渴望你的.exe :fatal error LNK1120:1 个无法解析的外部命令
c(7) :warning C4996:'gets':This function or variable may b vc2008#include#includemain(){FILE *fp;char str[81],name[10];gets(name);if((fp=fopen(name,"w"))==NULL){printf("can not open\n");exit(0);}gets(name);fputs(str,fp);flose(fp);if((fp=fopen(name,"r
fclose写成flose了!
gets有溢出风险,可改成fgets.
改法见注释:
#include
#include
main()
{
FILE *fp;
char str[81],name[10];
gets(name);
if((fp=fopen(name,"w"))==NULL)
{
printf("can not open\n");
exit(0);
}
gets(name); /* 这里改成 fgets(name,sizeof(name),stdin); */
fputs(str,fp);
flose(fp); /* 这里写错了!应该是fclose(fp); */
if((fp=fopen(name,"r"))==NULL)
{
printf("canfhhkjadf\n");
exit(0);
}
fgets(str,strlen(str)+1,fp);
printf("oiehjhsdhfkjdf\n");
puts(str);
fclose(fp);
}