0 c++ if-statement block braces
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’
Run Code Online (Sandbox Code Playgroud)
用户输入第一个名字后,我想提供输入第二个名字的选项.如果"N"只是跳到位置,如果"Y"转到Name2然后转到Location.