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