//文件的打开与关闭,将一个字符串写入到文件中
#include <stdio.h>
#include <stdlib.h>
int main()
{
char* str="weather";
FILE *fp=NULL;
if((fp=fopen("a.txt","w"))==NULL)
{
printf("文件打开失败\n");
return 0;
}
printf("文件打开成功\n");
while(*str!='\0')
{
fputc(*str++,fp);
}
fclose(fp);
system("PAUSE");
return 0;
}