Login Program

meghs007 0 Tallied Votes 191 Views Share

This program take user name and password from the use but the password not display on screen insted of password ***** display
Program by Meghdoot(meghs)

#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
	int i=0,temp=0,x;
	char pass[100];
	char user[]="meghdoot",password[]="meghs007";
	clrscr();
	printf("\n Enter User Name=");
	gets(user);
	printf("\n Enter Password=");
	while(temp!=13)
	{
	 pass[i]=getch();
	 temp=pass[i];
	 i++;
	 printf("*");
	}
	pass[i]=NULL;
	if((x=strcmp(password,pass))==0)
	{
		printf("\n Login Successful");
	}
	else
	{

		printf("\n User name or passord Wrong");
	}
	prinft("\n Program By Meghdoot ");
	
	getch();
}
MosaicFuneral 812 Nearly a Posting Virtuoso

Take note that, main() must return zero by standard, and conio.h doesn't exist on most compilers.

saroj_timsina 0 Newbie Poster

its assom

William Hemsworth 1,339 Posting Virtuoso

-Shouldn't use 'void main'
-Shouldn't use 'clrscr()'
-You can't backspace your password
-Doesn't compile for me, 'prinft' isn't a function

tux4life 2,072 Postaholic

MosaicFuneral>...and conio.h doesn't exist on most compilers
Actually I don't know a compiler where it doesn't exist, can you give me an example of this?

I only know the ones which are supporting it: Digital Mars compiler, OpenWatcom, Borland C++ Compiler, MinGW, I'm not sure whether the M$ compiler's support this :P

WH>You can't backspace your password
True, that's actually a very unpleasant user experience, but he can implement it :)

WH>Doesn't compile for me, 'prinft' isn't a function
He meant printf of course :P ...

WH>Shouldn't use 'clrscr()'
Agreed

WH>Shouldn't use 'void main'
Absolutely right!

saroj_timsina>its assom
No it isn't, it lacks the capability to use backspace to correct a typo ...

burnt-ice09 0 Newbie Poster

Hi guys! I'm also new here...

meghs007, I've tried running your program after some modifications. It seemes that there is an ADDITIONAL character being typed whenever you pressed the <ENTER> key. This character adds up to your default password, hence nullifying your entry.

Does anyone have an idea to fix this issue? Thanks!

By the way here's the modified program:

#include<stdio.h>
#include<conio.h>
#include<string.h>

int main()
{
    int i=0,temp=0,x;
    char pass[100];
    char user[]="meghdoot",password[]="meghs007";
//  clrscr();
    printf("\n Enter User Name=");
    gets(user);
    printf("\n Enter Password=");
    while(temp!=13)
    {
     pass[i]=getch();
     temp=pass[i];
     i++;
     printf("*");
    }
    pass[i]=0;
    if((x=strcmp(password,pass))==0)
    {
        printf("\n Login Successful");
    }
    else
    {

        printf("\n User name or passord Wrong");
    }
    printf("\n Program By Meghdoot ");

    getch();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.