Search
 
SCRIPT & CODE EXAMPLE
 

CPP

login system with c++

//Written by itsKrish01
//If you find any error or mistake in this code, then please contact me.

#include <iostream>


using namespace std;

int main() {

  string login;
  string user;
  int login_times;
  string password_login;
  string password;
  
  string command;

  cout << "exit/login/register"<<endl<<"Command: ";
  cin >> command;

  while(command != "exit"){

    if(command == "register"){
      cout << "

"<<endl;
      cout << "Registeration"<<endl<<"----------------"<<endl;
      cout <<"regsiter: ";
      cin >> user;
      cout <<"password: ";
      cin >> password; 

      cout << "

";
      cout << "Registered Successfully!"<<endl;
      cout << "

";
      cout << "exit/login/register"<<endl<<"Command: ";


      cin >> command;

      login_times = 3;
      while(login_times > 0){
        

        cout << "

";
        cout << "Login"<<endl<<"_____";
        cout << "
";

        cout << "login: ";
        cin >> login;
        cout << "Password: ";
        cin >> password_login;

        

        

        if(login == user && password_login == password){
          cout << "loged in Successfully!"<<endl;
          cout << "Welcome"<<user<<"!";
          
          break;

        }
        else if(login != user && password_login == password){

          cout << "username is incorrect!"<<endl;
          login_times--;
          
        }

        else if(login == user && password_login != password){

          cout << "password is incorrect!"<<endl;
          login_times--;
          
        }
        else{
          cout << "Everything is incorrect!"<<endl;
          login_times--;
        }

        

        


      }
      cout << "you have entered wrong details for more than 3 times, So we have blocked your account!";
      break;
    }

  }

}
Comment

PREVIOUS NEXT
Code Example
Cpp :: print counting in c++ 
Cpp :: double to float c++ 
Cpp :: C++ Infinite while loop 
Cpp :: length of number c++ 
Cpp :: find in unordered_map c++ 
Cpp :: cpp vector 
Cpp :: c++ find object in vector by attribute 
Cpp :: how to find the length of an array in cpp 
Cpp :: SUMOFPROD2 
Cpp :: c++ move semantics for `this` 
Cpp :: return array of string in function c++ 
Cpp :: string format decimal places c++ 
Cpp :: visual studio getline not working 
Cpp :: how to create a c++ templeate 
Cpp :: c++ shell 
Cpp :: overload subscript operator cpp 
Cpp :: how to sort array in c++ 
Cpp :: how to check char array equality in C++ 
Cpp :: C++ fibo 
Cpp :: Lambda capture as const cpp 
Cpp :: max c++ 
Cpp :: c++ check that const char* has suffix 
Cpp :: volumeof a sphere 
Cpp :: c++ stl vector get iterator from index 
Cpp :: tabeau dynamique c++ 
Cpp :: cpp vector popback 
Cpp :: c++ hash 
Cpp :: C++ Taking Multiple Inputs 
Cpp :: unique element in array in c 
Cpp :: replace a char in string c++ at a specific index 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =