Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@harish-OUjQxA • Sep 7, 2012
Well, so you take the input as password should be either in numbers of in characters right ? If that's the case,
just use the rand() function to generate what you need. -
@rahul69-97fAOs • Sep 7, 2012
Your question looks like password display problem rather than password creation..i guess..
So for display the simplest way is to take input using getch() along with a single printf("*"); statement inside a loop until user does not press enter.
PS: Some programmers would not recommend this because <conio.h> is not a standard headerfile. But for this case this is a valid solution.😀😁 -
@vishal-pysGmK • Sep 8, 2012
It's not that, some programs don't support getch() It's the programming environment which doesn't support this header as it is not the standard given by ANSI.rahul69Your question looks like password display problem rather than password creation..i guess..
So for display the simplest way is to take input using getch() along with a single printf("*"); statement inside a loop until user does not press enter.
PS: Some programmers would not recommend this because <conio.h> is not a standard headerfile. But for this case this is a valid solution.😀😁
You are right about printing the * but don't use printf() for that
printf is very expensive way to print just one character!
the reason for that are:
1> gets the format string
2> parse and analyze the string
3> find out that there's a CHAR format specifier
4> call the char output subfunction
5> gets the character parameter
6> output the character to the screen
So, the above things just to print a character, is a bad idea.. Use putchar('*');
😀
Algorithm for this part is something like thisanyone know then plz help me....I want to create password in c programminguser input will be int or char type and output should be in form of string like ******.
1) z = 0
2) run the loop
while( (c = getchar()) != 13) { password [z++] = c; putchar('*'); }3) after loop
password[z++] = '\0';
#-Link-Snipped-#
This is not completed yet!! what if the user enters a wrong password?? Think about it 😀 try to use backspace. Try fixing the problem! If you don't get it, post again.. 😀