IOday2

IOday2_第1张图片

 1.

  1 #include 
  2 #include 
  3 #include 
  4 #include 
  5 int main(int argc, const char *argv[])
  6 {
  7     FILE *p=fopen("ceshi.txt","r");
  8     if(NULL==p)
  9     {
 10         ERR_MSG("fopen");
 11         return -1;
 12     }
 13 
 14     char s[30];
 15     int count=0;
 16     while(fgets(s,sizeof(s),p)!=NULL)
 17     {
 18         count++;
 19     }
 20     printf("count=%d\n",count);
 21     fclose(p);
 22     return 0;
 23 }      

IOday2_第2张图片IOday2_第3张图片

2.

  1 #include 
  2 #include 
  3 #include 
  4 #include 
  5 int main(int argc, const char *argv[])
  6 {
  7     FILE *p1=fopen("ceshi.txt","r");
  8     if(NULL==p1)
  9     {
 10         ERR_MSG("fopen");
 11         return -1;
 12     }
 13     FILE *p2=fopen("t.txt","w");
 14     if(NULL==p2)
 15     {
 16         ERR_MSG("fopen");
 17         return -1;
 18     }
 19 
 20     char c;
 21     while(fread(&c,sizeof(c),1,p1)!=0)
 22     {
 23         fwrite(&c,sizeof(c),1,p2);
 24     }
 25 
 26     fclose(p1);
 27     fclose(p2);                                                                                  
 28     return 0;
 29 }

IOday2_第4张图片

3.xmind

IOday2_第5张图片

 

你可能感兴趣的:(c语言,linux)