-2
#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;
}

Console doesn't print the word "Admitted". It launches, but after my putting in the console words, repeatedly occur nothing.

I request your aid. Thank you.

Timur
  • 23
  • 6
  • goto is generally frowned on. See http://stackoverflow.com/questions/3517726/what-is-wrong-with-using-goto for some discussion of this. Perhaps a while loop would be better. – Ian May 30 '16 at 16:30

1 Answers1

1

You are comparing with errormsg == checkpass(password); when you should assign with one = symbol.

Ian
  • 572
  • 1
  • 4
  • 17