Advertisement
Guest User

Untitled

a guest
May 26th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. void tr(Thesaurus& thes) {
  2. char* word = (char*)malloc(sizeof(char) * 256);
  3. printf("Enter the word you want to see translation for\n");
  4. (void)scanf("%s", word);
  5. word = (char*)realloc(word, sizeof(char) * (strlen(word) + 1));
  6.  
  7.  
  8.  
  9. if (word[0] > 'A' && word[0] < 'z') {
  10. auto it = thes.eng.begin();
  11. for (it; it != thes.eng.end(); ++it) {
  12. if (strcmp((*it).word, word) == 0) {
  13. printf("%10s - %s\n", word, (*it).tr);
  14. break;
  15. }
  16. }
  17. if (it == thes.eng.end()) printf("No such word in Thesaurus.\n");
  18. }
  19. else {
  20. auto it = thes.rus.begin();
  21. for (it; it != thes.rus.end(); ++it) {
  22. if (strcmp((*it).word, word) == 0) {
  23. printf("%10s - %s\n", word, (*it).tr);
  24. break;
  25. }
  26. }
  27. if (it == thes.rus.end()) printf("No such word in Thesaurus.\n");
  28. }
  29.  
  30. free(word);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement