Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Login Program which Inputs the Password in Hidden Form, but the correct Login is shown Incorrect.

–1 vote
asked Jun 10, 2018 by Arslan K Q (160 points)
/*This is a C++ Program. This Program asks the User to Enter their Username and Password

(Password is Input in Hidden form"*"), after doing so the Program compares that is Username equals to "admin" and

is password equals to "abc123".*/

//The Problem is that it shows that the Login is not correct even though I Input the correct information.





using namespace std;

int main()



  string username;

  cout<<"please Enter your Username: ";

  getline(cin, username);

  cout<<"Please Enter Your Password: ";

  char password[32];

  int i=0;

  char a;












      cout<<"\b \b";









  cout<<"\nYour username is: "<<username;

  cout<<"\nYour Password is: "<<password;







  cout<<"\nWrong Username or Password, please Try again\n";

  goto tryagain;


  return 0;


1 Answer

0 votes
answered Jun 12, 2018 by Michał Ostrowski (140 points)
edited Jun 12, 2018 by Michał Ostrowski

I'm not sure but Maybe you compare string with poiter to char[]  here:




 if(username=="admin"&&( strcmp (password,"abc123"))!=1 )

Or do it by char.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.