Password Program In C Programming

password-program-in-c-programming



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:

The simple password program in c programming will be like this:

#include <stdio.h>
#include <string.h>
int main(void)
{
    const char password[15] = "allow";
    const char username[15]="farhan";
    char pass[15],user[15];
    int x,i;
    int log = 0;
    clrscr();
    printf("Enter Username: ");
    scanf("%s",&user);
    printf("Enter your password: ");
    scanf("%s", &pass);
    if(strcmp(pass, password) != 0 && strcmp(user, username) !=0)
    {
log = 1;
    }
    else
    {
for(x = 0; x < strlen(pass); x++)
{
for(i=0; i<strlen(user);i++)
{if(user[i]!=username[i])
  { log=1;}
   if(pass[x] != password[x])
   {
log = 1;
break;
   }
}
    }}
    if(log == 0)
    {
printf("\nSuccessful login...\n");
    }
    else
    {
printf("\nInvalid password! or Username\n");
    }

    getchar();

    getch();
    return 0;

Output Of Password Program:

password-program-in-c-programming

Feature Of Password Program in C Programming:

The main features of adding or learning password program are:
  • For loops are used.
  • If and else conditions are used.
  • String functions are used.

String Functions:

  1. strcmp is a string function used to compare two strings.
  2. strlen is another string function used to calculate the length of a string.

Conclusion:

I have provided you password program in c programming for your help. If you are feeling any difficulty in this program feel free to comment below.

Paasword program in c programming is very useful program. Password program in c programming can be used to secure your program. 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.

Labels:

Post a Comment

Thanks for your feedback.

[blogger]

About Me

{picture#https://plus.google.com/photos/116258869433881638604/albums/profile/6443768328931686658} I am youngest passionate blogger from Pakistan. I love blogging about SEO, earn online, blogger and wordpress {facebook#YOUR_SOCIAL_PROFILE_URL} {twitter#YOUR_SOCIAL_PROFILE_URL} {google#https://plus.google.com/116258869433881638604} {pinterest#YOUR_SOCIAL_PROFILE_URL} {youtube#YOUR_SOCIAL_PROFILE_URL} {instagram#YOUR_SOCIAL_PROFILE_URL}

Contact Form

Name

Email *

Message *

Pro Bloggerism. Powered by Blogger.