Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(void) {
  5.   char word[80];
  6.   char plural[80];
  7.   char *ending;
  8.   int last;
  9.  
  10.   while (1) {
  11.     printf("> ");
  12.     fgets(word, 80, stdin);
  13.  
  14.     last = strlen(word) - 1;
  15.     word[last] = '\0';
  16.  
  17.     if (strcmp(word, "Q") == 0)
  18.       break;
  19.    
  20.     strncpy(plural, word, 80);
  21.  
  22.     switch (word[last]) {
  23.     case 'y':
  24.       plural[last] = '\0';
  25.       ending = "ies";
  26.       break;
  27.  
  28.     case 'h':
  29.       if (word[last - 1] != 's' && word[last - 1] != 'c')
  30.         break;
  31.  
  32.     case 's':
  33.       ending = "es";
  34.       break;
  35.  
  36.     default:
  37.       ending = "s";
  38.     }
  39.  
  40.     strcat(plural, ending);
  41.     printf("%s -> %s\n", word, plural);
  42.  
  43.   }
  44.  
  45.  
  46.   return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement