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>...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 ...

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();
}

Edited 3 Years Ago by Reverend Jim: Fixed formatting