Advertisement
Guest User

Leitura de palavras

a guest
Nov 16th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <string.h>
  2. #include<stdio.h>
  3.  
  4.  
  5.  
  6. int main (void){
  7.  
  8. char palavras[20];
  9. int bola, outras;
  10. bola = outras=0;
  11.  
  12. FILE *fp;
  13.  
  14. fp= fopen("palavras.txt","r");
  15.  
  16.  
  17. if(fp == NULL){
  18.  
  19. printf("Arquivo nao encontrado \n");
  20.  
  21. }
  22. while(fgets(palavras,20,fp)!=NULL){
  23.  
  24. if((strcmp(palavras,"bola")==0)){
  25. bola++;
  26. outras;
  27. }
  28.  
  29. outras++;
  30. printf("%s",palavras);
  31.  
  32. }
  33.  
  34. printf("Quantidade de palavras \n %i",outras);
  35. printf("Quantidade de bola \n %i",outras);
  36.  
  37. fclose(fp);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement