View Single Post
Old Nov 18th, 2005, 5:14 PM   #9
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
Here - I fixed the first block - you can duplicate it down into the other if blocks.
#include <stdio.h>
#include <string.h>

int main (void)
{
 char input[30]={0x0}; /* initialize the string */
 int len=0;

 printf("Please enter a noun(up to 28 characters) to pluarize:");
 fgets(input,sizeof(input),stdin);  /* prevent user enter LARGE word to crash
                                           this program */
 
 len=strlen(input);  /* add an if statment to be sure your word is okay length */
 len--;                 /* characters start counting from zero, not one 
                             so the last character of the string is len-1 -- 
                              len-- decrements len */
 if(input[len]=='y')
 {
  input[len]='i';
  input[len+1]='e';
  input[len+2]='s';
 }
  /* it works just fine up to here */
jim mcnamara is offline   Reply With Quote