nikolas_serafini

Lista 10 - Exercício 3

Aug 27th, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define FILENAME "testx.c"
  4.  
  5. int main(){
  6.     int i = 0,j, counter = 0;
  7.     char s[50][100];
  8.  
  9.     FILE *fp;
  10.  
  11.     fp = fopen(FILENAME,"r");
  12.  
  13.     while (fgets(s[i],100,fp) != NULL)
  14.         i++;       
  15.  
  16.     fclose(fp);
  17.  
  18.     fp = fopen(FILENAME,"w");
  19.    
  20.     for(j = 0; j < i; j++)
  21.         fprintf(fp,"/* %d */   %s",counter++,s[j]);
  22.  
  23.     fclose(fp);
  24.    
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment