Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main(void) {
- char word[80];
- char plural[80];
- char *ending;
- int last;
- while (1) {
- printf("> ");
- fgets(word, 80, stdin);
- last = strlen(word) - 1;
- word[last] = '\0';
- if (strcmp(word, "Q") == 0)
- break;
- strncpy(plural, word, 80);
- switch (word[last]) {
- case 'y':
- plural[last] = '\0';
- ending = "ies";
- break;
- case 'h':
- if (word[last - 1] != 's' && word[last - 1] != 'c')
- break;
- case 's':
- ending = "es";
- break;
- default:
- ending = "s";
- }
- strcat(plural, ending);
- printf("%s -> %s\n", word, plural);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement