C++ Program to Check Valid User name and Password

Write C++ Program to Check Valid User name and Password

// CPP Program to Check Valid User name and Password

#include <iostream>
#include <string.h>

using namespace std;

int main()
{
	int flag1 = 0,flag2 = 0;
	char user_name[] = "CodeCrucks";
	char user_password[] = "[email protected]";

	char user_name1[20];
	char user_password1[20];

	cout << "Enter Username :--> ";
	gets(user_name1);

	cout << "Enter Password :--> ";
	gets(user_password1);
	if((strcmp(user_name, user_name1) == 0) && (strcmp(user_password, user_password1) ==0 ))
        {
		cout << "Success";
	}
	else
	{
		cout << "Failure";
	}

	return 0;
}

Output:

Run 1:
Enter Username :--> CodeCrucks
Enter Password :--> [email protected]
Success

Run 2:
Enter Username :--> CodeCrucks
Enter Password :--> [email protected]
Failure

≪ Previous | Next ≫