Question:

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

by Guest22654016  |  1 year, 3 month(s) ago

0 LIKES UnLike

/* 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;
}

 Tags: Error, exception, getting, im, Program, unhandled, writing

   Report
SIMILAR QUESTIONS

Question Stats

Latest activity: 1 year, 3 month(s) ago.
This question has been viewed 226 times and has 0 answers.

1 User is following this question

chaindog2003

BECOME A GUIDE

Share your knowledge and help people by answering questions.