I am writing a monogram program that allows user to enter full name (first, middle, and last name). The program will get all three initials of each name and put them together in a monogram.
It worked fine until I want to loop and do another monogram. I get this error after I enter 'y' when it asks me to do another monogram:
"Unhandled exception at at 0x76C0C54F in Problem Set Strings Monogram.exe: Microsoft C++ exception: std::out_of_range at memory location 0x003BFA4C."
I think it has something to do with the while loop, but it seems fine to me. I am just a beginner still so any help would be great. Thanks in advance!!
int _tmain(int argc, _TCHAR* argv)
cout << "Enter your full name (first middle last): ";
firstInitial = fullName; //gets first initial
positionOffirstSpace = fullName.find(" "); //gets position of first space
secondInitial = fullName[positionOffirstSpace+1]; //gets intial of middle name by adding 1 to position of space
fullName.erase(positionOffirstSpace,1); //erases first space to allowing for second space to be found later
positionOfsecondSpace = fullName.find(" "); //gets position of second space
thirdInitial = fullName[positionOfsecondSpace+1]; //gets intial of last name by adding 1 to position of space
cout << firstInitial << thirdInitial << secondInitial << endl << endl;
cout << "Would you like to do another???(y or n) ";
cin >> doAgain;