C语言关于IO文件的操作

求助:尽可能少的改程序使得运行结果产生一个含10个welcome to\n字符串的temp.txt文件

代码如下:

#include<stdio.h>
#include<string.h>
int main(int argc,char*argv[])
{
     int i=0;
     FILE *fp=fopen("temp.txt","w+");
     char string[]="WELCOME TO \n";
     char secondstring[]="welcome to\n";
     char temp[sizeof(string)];
     for(i=0;i<10;i++)
     fputs(string,fp);
     fseek(fp,0,SEEK_SET);
     while((fgets(temp,sizeof(string),fp))!=NULL)
     {
         fseek(fp,-(long)sizeof(temp),1);
         fputs(secondstring,fp);
     }
     fclose(fp);
     return 0;  
 } 

改好的代码,如果加上注释就更棒了

函数原型:
size_t fread ( void * ptr, size_t size, size_t count, FILE * stream );       所在头文件 : <cstdio>
Read block of data from stream  从文件流中读取count个元素,元素的大小是size字节,存储到p......
答案就在这里:C语言文件IO操作
----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。

http://blog.csdn.net/ych_ding/article/details/42044391