c语言库函数
#include <stdio.h>
#define LENGTH 100
main()
{
FILE *fd;
char str[LENGTH];
fd = fopen("hello.txt", "w+"); /* 创建并打开文件 */
if (fd)
{
fputs("Hello, Software Weekly", fd); /* 写入Hello, software weekly字符串 */
fclose(fd);
}
fd = fopen("hello.txt", "r");
fgets(str, LENGTH, fd); /* 读取文件内容 */
printf("%s\n", str);
fclose(fd);
}
创建hello.txt 文件,并往里面写入“Hello, Software Weekly”;

浙公网安备 33010602011771号