Advertisement
Guest User

pag18

a guest
Nov 27th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.  
  6.     FILE * pFile;
  7.     char ch;
  8.  
  9.     int iLetras=0, iEspacos=0, iTabs=0,iNL=0, i;
  10.  
  11.     pFile = fopen("DollarSignText.txt","r");
  12.  
  13.     if (pFile == NULL) perror("Erro na abertura do arquivo");
  14.     else
  15.     {
  16.         while(1)
  17.         {
  18.             ch = fgetc(pFile);
  19.             if (ch==EOF) break;
  20.             //printf("%c", ch);
  21.             if (isalpha(ch)) iLetras++;
  22.             else if (ch==' ') iEspacos ++;
  23.             else if (ch=='\t') iTabs++;
  24.             else if (ch== '\n') iNL++;
  25.  
  26.  
  27.         }
  28.     }
  29.  
  30.     printf("Num. letra(s) %d\nNum. Espaco(s) %d\nNum. Tab(s) %d\nNum. Nova linha(s) %d",iLetras, iEspacos, iTabs,iNL);
  31.  
  32.     fclose(pFile);
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement