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
", str);
 fclose(fd);
}

  创建hello.txt 文件,并往里面写入“Hello, Software Weekly”;

原文地址:https://www.cnblogs.com/oxspirt/p/6091104.html