Quantcast
Channel: MaybeNow | Looking for writing
Viewing all articles
Browse latest Browse all 144

I'm getting an unhandled exception error in a c program I'm writing

$
0
0
/* Phillip Standifer PigLatin converter 20110206 */ #include #include using namespace std; string PigLatin(string engStr); void main() { bool cont=true; string engStr, pigStr; cout << "*** You will be prompted to enter a string of ***" << endl<< "*** words. The string will be converted into ***" << endl<< "*** Pig Latin and the results displayed. ***" << endl<< "*** Enter as many strings as you would like. ***" << endl; while (cont==true) { cout << "Please enter a string of words or press ENTER to quit:" << endl; getline(cin,engStr); if(engStr=="") {break;} cout << endl << "Your original string was: " << endl << engStr << endl; pigStr = PigLatin(engStr); cout << endl << "Your string converted to pig latin is: " << endl; cout << pigStr << endl; } } string PigLatin(string engStr) { string newString, word; size_t start, begin; start=begin=0; bool loop=true; while(loop==true) { engStr.find(' ',start); if(start==string::npos) {break;} engStr.substr(start, start-begin); newString += word; newString += begin; newString += "ay "; start++; begin=start; } engStr.substr(start, start-begin); newString += word; newString += begin; newString += "ay "; return newString; }

Viewing all articles
Browse latest Browse all 144

Trending Articles