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[] = "cc@123"; 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 :--> cc@123
Success
Run 2:
Enter Username :--> CodeCrucks
Enter Password :--> abc@123
Failure