Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. void handle_file(){
  2. char str[100000];
  3. char str2[100000];
  4. while (!feof(file)){
  5. if (fgets(str, sizeof(str), file) != NULL){
  6. sprintf(str2, convert_to_lower(str));
  7. char s[] = "§½£#¤&´\%%%@$0123456789+ —–-|/\"\\()[]{}<>,:;.=_?*!\n\t"; //the list of characters that the words are separated with
  8. char *token = strtok(str2, s);
  9.  
  10. /* walk through other tokens */
  11. while( token != NULL ) {
  12. if(token != NULL){
  13. for(k=0; k<n; k++){
  14. if(firstTime = 0){
  15. FLAG = 0;
  16. firstTime = 1;
  17. break;
  18. }
  19. //////MODAUS ALKAA
  20. if(strcmp(words[k].singleword,token) == 0){
  21. FLAG = 1;
  22. break;
  23. }
  24.  
  25. else{
  26. FLAG = 0;
  27. }
  28. } //for
  29.  
  30. if(FLAG == 1){
  31. words[k].occurrenceTimes++;
  32. }
  33.  
  34. if(FLAG == 0){
  35. strcpy(words[n].singleword, token);
  36. words[n].occurrenceTimes++;
  37. n++;
  38. }
  39. }
  40.  
  41.  
  42. token = strtok(NULL, s);
  43.  
  44. }
  45.  
  46. }//if
  47.  
  48. }//while
  49.  
  50.  
  51. //return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement