fork download
  1. #include <stdio.h>
  2.  
  3. void REMOVE_WORD (int howmanylines)
  4. {
  5.  
  6. FILE *fp;
  7. if ((fp=fopen("words.txt", "r+w"))==NULL)
  8. {printf("Error while opening the file!\n");
  9. exit(1);}
  10. else
  11. {
  12. typedef struct base
  13. {
  14. struct base *next;
  15. char word[25];
  16. char category[15];
  17. } list_els;
  18.  
  19. struct base tab[howmanylines];
  20. int i=0;
  21. while (!feof(fp))
  22. {
  23. fscanf(fp, "%s", &tab[i].word);
  24. fscanf(fp, "%s", &tab[i].category);
  25. i++;
  26. }
  27.  
  28. fclose(fp);
  29.  
  30. list_els *head;
  31. list_els *el=(list_els*)malloc(sizeof(list_els));
  32. list_els *ind=head;
  33. while (ind->next)
  34. {
  35. ind=ind->next;
  36. ind->next=el;
  37. }
  38.  
  39.  
  40.  
  41. printf("What word do you want to remove?\n\n");
  42. char word_remove[25];
  43. scanf("%s", &word_remove);
  44. if (strcmp(ind->next->word, word_remove)==0)
  45. {
  46. printf("Found:\n Word: | Category:\n %s | %s\n", ind->next->word, ind->next->category);
  47. printf("Are you sure you want to remove?\n1)Yes\n 2)No\n\n");
  48. int removing;
  49. if (removing==1)
  50. {
  51. list_els *removed=ind->next;
  52. ind->next=removed->next;
  53. free(removed);
  54. }
  55. else if (removing==2) {printf("Removing cancelled.\n\n");}
  56. else {printf("Wrong operation number!");}
  57. }
  58. else printf("Word not available in the base!\n\n");
  59. }
  60. }
  61.  
  62. int main(void) {
  63. // your code goes here
  64. return 0;
  65. }
  66.  
Success #stdin #stdout 0s 2244KB
stdin
Standard input is empty
stdout
Standard output is empty