cant figure out how to get this to work.
every thing seems find but i cant get if some one enter some thing other then y s ch sh
add a 's' to the end of it.
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
void findPlural(char * input, char* &plural);
void findPlural(char * input, char* &plural)
{
int lenght;
lenght = strlen(input);
if (input[lenght -1] == 'y')
{
strcpy(plural,input);
input[lenght -1] = 'i';
strcat(plural, "es");
}
else if (input[lenght -1] == 's'|| 'ch' || 'sh')
{
strcpy(plural,input);
input[lenght -1] = 'e';
strcat(plural, "s");
}
else if (input[lenght -1] != 's'||'ch'||'sh'||'y')
{
strcpy(plural,input);
input[lenght -1] = 's';
strcpy(plural,input);
}
}
int main ()
{
char noun[30];
char * pural;
pural = new char[30];
cout << "Enter a noun" ;
cin >> noun;
findPlural(noun, pural);
cout << " The Plural of " << noun << " is " << pural << endl;
return 0;
}
its doing my head in.... also for some reason the Noun should read out what i type in and the pural should have Either s,es, ies to to end of the String/Char..