#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char* argv[])
{
{
FILE* fp;
fp = fopen("test.txt", "w");//写文件
if (fp != NULL)
fprintf(fp, "Hello %s\n", "zhangsan");
fclose(fp);
}
{
FILE* fp;
fp = fopen("test.txt", "r");//读文件
char str[1024] = { 0 };
if (fp != NULL)
fscanf(fp,"Hello %s\n",str);
printf(str);
fclose(fp);
}
system("pause");
return EXIT_SUCCESS;
}
C语言-文件读写fprintf,fscanf
最新推荐文章于 2024-11-06 23:59:11 发布