Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void PreencheTabelaPalavras ( char *ficheiro, st_texto *t )
- {
- FILE *f;
- int n,l;
- char *palavra;
- f = AbreFicheiro ( ficheiro, "r" );
- while ( ( palavra = LePalavra ( f ) ) != NULL ) {
- if ( ( n = NovaPalavra ( palavra, &(*t) ) ) == -1 ) {
- l=strlen(palavra);
- (*t).palavras[(*t).n_dist_palavras] = (char *)malloc(sizeof(char) * (l+1)) /* -- Insert code for memory allocation --*/;
- if ( (*t).palavras[(*t).n_dist_palavras] == NULL ) {
- fprintf ( stderr, "ERROR: not enough memory available!\n" );
- exit ( 3 );
- }
- strcpy ( (*t).palavras[(*t).n_dist_palavras], palavra );
- (*t).ocorrencias[(*t).n_dist_palavras]++;
- (*t).n_dist_palavras++;
- }
- else {
- (*t).ocorrencias[n]++;
- }
- }
- fclose ( f );
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement