linux设备驱动学习点滴(一),简单的文件操作

来源:互联网 发布:java支付接口开发流程 编辑:程序博客网 时间:2024/06/17 00:37

fopen.c

#include<stdio.h>
#define LENGTH 100
main()
{
 FILE *fd;
 char str[LENGTH];
 fd=fopen("hello.txt","w+");
 if(fd)
 {
  fputs("hello world",fd);
  fclose(fd);
 }
 fd=fopen("hello.txt","t");
 fgets(str,LENGTH,fd);
 printf("%s/n",str);
 fclose(fd);
}

 

 

gcc -o fopen fopen.c

在相应文件夹里产生hello.txt