Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*****************************************************************************************
- * PROGRAM: Pluralizer.cpp
- * AUTHOR: Zachary Kerns Some portions assisted by David Bowles
- * DATE:
- * CLASS: CTCH 233 Winter 2011
- *
- * USAGE: pluralizer.exe
- *
- * DESCRIPTION:
- * The Pluralizer takes nouns and converts them to their plurals.
- *
- *
- *
- *****************************************************************************************/
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- //Global variables.
- int i = 0;
- int convert = 1;
- char noun[20];
- void pluralizer(char *noun);
- void endProgram(int convert);
- int main()
- {
- while (convert !=0)
- {
- endProgram(convert);
- printf("Please enter a noun: ");
- scanf("%s", noun);
- //Start the pluralizing action.
- pluralizer(noun);
- printf("%s\n", noun);
- }
- return 0;
- }
- void pluralizer(char *noun)
- {
- int i = strlen(noun);
- if ((noun[i - 1] == 's'))
- {
- strcat(noun, "es");
- }
- else if ((noun[i - 2] == 'c') && ((noun[i - 1] == 'h')))
- {
- strcat(noun, "es");
- }
- else if ((noun[i - 2] == 's') && ((noun[i - 1] == 'h')))
- {
- strcat(noun, "es");
- }
- else if (noun[i - 1] == 'y' )
- {
- noun[(strlen(noun) - 1)] = '\0';
- noun[(strlen(noun) - 1)] = '\0';
- (strcat(noun, "ies"));
- }
- else
- {
- strcat(noun, "s");
- }
- }
- void endProgram(int convert)
- {
- //Having trouble getting all of this to work
- if (strcmp(noun, "done") !=0)
- convert = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement