Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void handle_file(){
- char str[100000];
- char str2[100000];
- while (!feof(file)){
- if (fgets(str, sizeof(str), file) != NULL){
- sprintf(str2, convert_to_lower(str));
- char s[] = "§½£#¤&´\%%%@$0123456789+ —–-|/\"\\()[]{}<>,:;.=_?*!\n\t"; //the list of characters that the words are separated with
- char *token = strtok(str2, s);
- /* walk through other tokens */
- while( token != NULL ) {
- if(token != NULL){
- for(k=0; k<n; k++){
- if(firstTime = 0){
- FLAG = 0;
- firstTime = 1;
- break;
- }
- //////MODAUS ALKAA
- if(strcmp(words[k].singleword,token) == 0){
- FLAG = 1;
- break;
- }
- else{
- FLAG = 0;
- }
- } //for
- if(FLAG == 1){
- words[k].occurrenceTimes++;
- }
- if(FLAG == 0){
- strcpy(words[n].singleword, token);
- words[n].occurrenceTimes++;
- n++;
- }
- }
- token = strtok(NULL, s);
- }
- }//if
- }//while
- //return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement