Advertisement
Guest User

Carregar

a guest
Apr 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. void ExecutarFuncao1(estrutura_dados_t *estrutura) {
  2.   FILE *ficheiro;
  3.   char texto[MAX_TEXTO_PARAGRAFO];
  4.   char *palavra;
  5.  
  6.   ficheiro = fopen(estrutura->NomeFicheiro, "r");
  7.  
  8.   if (!ficheiro) {
  9.     printf("\nFicheiro %s não encontrado!\n", estrutura->NomeFicheiro);
  10.     return;
  11.   }
  12.   else {
  13.     while (!feof(ficheiro)) {
  14.       // Ler palavras do ficheiro
  15.       fgets(texto, MAX_TEXTO_PARAGRAFO, ficheiro);
  16.  
  17.       palavra = strtok(texto, DELIMITADOR_PALAVRAS);
  18.  
  19.       while (palavra != NULL) {
  20.         inserir_palavra_lista_inicio(estrutura->lista, palavra);
  21.         palavra = strtok(NULL, DELIMITADOR_PALAVRAS);
  22.       }
  23.     } // Fim do While
  24.   } // Fim do Else
  25.  
  26.   system("cls");
  27.   printf("\nAcabado com sucesso\n");
  28.   system("pause");
  29.   fclose(ficheiro);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement