#include #include #include "dicionario.h" /* 1. Tornar o buffer dinâmico; 2. Tornar o word boundary mais inteligente. */ #define SIZE 200 int main() { char buffer[SIZE]; int index, c, ocorr; Dicionario dic1; Palavras pal; /* initalize variables */ c = 1; index = 0; buffer[index] = '\0'; initDic(&dic1); /* process standard input */ while(c != EOF) { c = getchar(); if( !isalpha(c) && c != '-' && index) /* whitespace found */ { buffer[index] = '\0'; /* cap the string */ acrescenta (&dic1, buffer); index = 0; /* reset index */ } else if(isalpha(c) || c == '-') /* keep filling the buffer */ { buffer[index] = c; index++; } } pal = maisFreq(dic1); printf("Palavra mais freq: %s com %d ocorrências.\n\n", pal->palavra, pal->ocorr); showDic(dic1); // destroiDic(&dic1); // showDic(dic1); return(0); }