#include
int main()
{
FILE *fp = NULL;
char str[50] = {0};
fp = fopen("c:\\a.txt","w");
if(fp==NULL)
{
printf("file write error!\r\n");
return -1;
}
fputs("hello world!\n",fp);
fclose(fp);
fp = NULL;
fp = fopen("c:\\a.txt","r");
if(fp==NULL)
{
printf("file read error!\r\n");
return -2;
}
fgets(str,sizeof(str),fp);
fclose(fp);
printf("%s",str);
return 0;
}