while(true)
{
cout << "Name: ";
getline(cin, Name);
if(Name == "Stop")
break;
cout << "Additional Name - Y/N: ";
getline(cin, additional);
if (additional == "Y")
cout << "Additional Name: ";
getline(cin, Name2);
else
cout << "Location: ";
getline(cin, Location);
if(Location == "Stop")
break;
}
chief.cpp: In member function ‘void BookList::Fill()’:
chief.cpp:128: error: ‘else’ without a previous ‘if’
After the user enters the first name, I would like to give the option to enter a second name. If "N" just skip down to Location, if "Y" go to Name2 and then on to Location.
You have to enclose the statements between the if
and the else
within brackets {
... }
.