好好爱自己!

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”;

posted @ 2016-11-22 20:55  立志做一个好的程序员  阅读(226)  评论(0编辑  收藏  举报

不断学习创作,与自己快乐相处