所以我得到一个编译错误,上面写着: 12 C:\Dev-Cpp\login.cpp expected unqualified-id before "while" 12 C:\Dev-Cpp\login.cpp expected ,' or
;' 在“while”之前 C:\Dev-Cpp\Makefile.win [构建错误] [login.o] 错误 1
这是我的代码:
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string username;
string password;
int attemptCount = 0;
}
while ( attemptCount < 3 )
{
cout << "Enter your username: " << endl;
cin >> username;
cout << "Enter your password: " << endl;
cin >> password;
if ( username != "Invitado" && password != "abel" )
{
int choice;
bool gameOn = true;
while (gameOn != false){
cout << "\n\n\n\n\n\n\n\n\n\n\n";
cout << " 1 - Inicia el juego.\n\n";
cout << " 2 - Modo Historia.\n\n";
cout << " 3 - Ayuda.\n\n";
cout << " 4 - Salir.\n\n";
cout << "\n\n\nElige tu opcion\n\n\n ";
cin >> choice;
switch (choice)
{
case 1:
cout << "\n\n\n\nBienvenido al juego...!\n";
// rest of code here
break;
case 2:
cout << "\n\n\n Este es el progreso hasta el momento\n";
// rest of code here
break;
case 3:
cout << "\n\n\n\n\n\n\n\nPara ayuda, por favor visite www.blabla.com!\n";
// rest of code here
break;
case 4:
cout << "\n\n\nFin del programa.\n";
gameOn = false;
break;
default:
cout << "\n\n\nNo es una opcion valida. \n";
cout << "\n\n\nElige de nuevo.\n";
cin >> choice;
break;
}
}
return 0;
}