#include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
string checkpass(string password1)
{
string rightpass = "aimen";
string errormsg2;
if (password1 == rightpass)
{
errormsg2 = "Right";
}
else{errormsg2 = "No";}
return errormsg2;
}
int main()
{
string password;
string errormsg;
cout << "Type the password";
loop:
getline (cin,password);
errormsg == checkpass(password);
if (errormsg=="Right")
{
cout << "Admitted" << endl;
}
else {
goto loop;
}
system("pause");
return 0;
}
Konsole druckt nicht das Wort "zugelassen". Es startet, aber nach dem Einsetzen der Konsole Worte, wiederholt nichts passieren.Problem mit dem Erstellen einer Schleife
Ich bitte um Hilfe. Vielen Dank.
goto ist in der Regel verpönt. Siehe http://stackoverflow.com/questions/3517726/what-is-wrong-with-using-goto für eine Diskussion darüber. Vielleicht wäre eine While-Schleife besser. – Ian