文章目录
读出点文件的东西windows下fopen注意点fopen': This function or variable may be unsafe. Consider using fwindows文件必须要用/,不能是windows默认的反斜杠\
VS下打开文件写点东西到文件!
读出点文件的东西
#include <stdio.h>
int main()
{
FILE
* f
= fopen("/home/ztz123/Desktop/data/base/16384/16385", "r");
int a
;
fseek(f
,20,SEEK_SET);
fscanf(f
,"%d",a
);
printf("%d\n",a
);
fclose(f
);
return 0;
}
windows下fopen注意点
fopen’: This function or variable may be unsafe. Consider using f
加上这个就好
#pragma warning(disable:4996)
windows文件必须要用/,不能是windows默认的反斜杠\
#include <stdio.h>
#pragma warning(disable:4996)
int main()
{
FILE
* f
= fopen("D:/walk_sample.txt", "r");
printf("%d\n", f
);
printf("%d\n", sizeof(int*));
fclose(f
);
return 0;
}
VS下打开文件写点东西到文件!
#include <stdio.h>
#pragma warning(disable:4996)
int main()
{
FILE
* f
= fopen("D:/a.txt", "a+");
fprintf(f
,"%d\n",234);
fclose(f
);
return 0;
}
在笔记本的虚拟机上去掉#pragma就好了,
仍然可以运行