/* * yo dawg.cpp * * Created on: Nov 19, 2009 * Author: SchmoSalt */ #include #include using namespace std; void addPlural(const char str[], char replace[], int len); int main() { char yoDawg[3][32]; cout << "sup dawg.\nNoun: "; cin.getline(yoDawg[0],31); addPlural(yoDawg[0],yoDawg[1],31); cout << "Verb: "; cin.getline(yoDawg[2],31); cout << "---\nyo dawg, we herd u like " << yoDawg[1]; cout << " so we put a " << yoDawg[0]; cout << " in ur " << yoDawg[0]; cout << " so u can " << yoDawg[2]; cout << " while u " << yoDawg[2]; cout << "\n\nPress Enter to quit."; cin.get(); return 0; } void addPlural(const char str[], char replace[], int len) { int lastChar; for(int x=0; x < len;x++) { replace[x] = str[x]; if(str[x] == '\0') { lastChar = x-1; break; } } if(replace[lastChar] == 'y' || replace[lastChar] == 'Y') { if(lastChar+1 < len) { replace[lastChar] = 'i'; replace[lastChar+1] = 'e'; replace[lastChar+2] = 's'; } } else if(replace[lastChar] == 's' || replace[lastChar] == 'S') { if(lastChar+1 < len) { replace[lastChar+1] = 'e'; replace[lastChar+2] = 's'; } } else { if(lastChar < len) { replace[lastChar+1] = 's'; } } return; }