If you had made a project in c programming and want to add user name and password protection on it. Then you are lucky that you find this blog. The password is the most common way to protect any thing from another user or to limit users to use this program.
In c programming, you can easily add password program in any other c program. In this tutorial, I will provide you password program in c programming. So let’s start.
Note: After password program, you must add loading program to make you project more attractive.
Password Program In C Programming:
const char password = “allow”;
const char username=”farhan”;
int log = 0;
printf(“Enter Username: “);
printf(“Enter your password: “);
if(strcmp(pass, password) != 0 && strcmp(user, username) !=0)
log = 1;
for(x = 0; x < strlen(pass); x++)
if(pass[x] != password[x])
log = 1;
if(log == 0)
printf(“nInvalid password! or Usernamen”);
Output Of Password Program:
Feature Of Password Program in C Programming:
- For loops are used.
- If and else conditions are used.
- String functions are used.
- strcmp is a string function used to compare two strings.
- strlen is another string function used to calculate the length of a string.