Advertisement
domdealm

Preprova - 3

Feb 23rd, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int main(){
  5.  
  6.     FILE * texto;
  7.     texto = fopen("linhas.txt","r");
  8.     char str[500];
  9.     int num=0;
  10.     if(texto == NULL){
  11.             printf("Erro, nao foi possivel abrir o arquivo\n");
  12.     }
  13.     else{
  14.  
  15.         while(!feof(texto)){
  16.                 printf("%d - ",num+1);
  17.                 fgets(str,300,texto);
  18.                 printf("%s",str);
  19.                 num++;
  20.     }
  21.     fclose(texto);
  22.     system("PAUSE");
  23.     return 0;
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement