Password : C - Programming

anyone know then plz help me....I want to create password in c programming
user input will be int or char type and output should be in form of string like ******.

Replies

  • Harish Kotra
    Harish Kotra
    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
    rahul69
    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 is not a standard headerfile. But for this case this is a valid solution.๐Ÿ˜€๐Ÿ˜
  • Vishal Sharma
    Vishal Sharma
    rahul69
    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 is not a standard headerfile. But for this case this is a valid solution.๐Ÿ˜€๐Ÿ˜
    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.

    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('*');
    ๐Ÿ˜€

    anyone know then plz help me....I want to create password in c programmingโ€‹
    user input will be int or char type and output should be in form of string like ******.โ€‹
    Algorithm for this part is something like this

    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.. ๐Ÿ˜€

You are reading an archived discussion.

Related Posts

can anyone explain me How Data mining is different from knowledge discovery in database ?
What are the possible ways to create a multi-player game environment for 3-4 Players on Mobile Phones? Can it possible using Bluetooth Technology? help needed asap..
can anyone explain in simple terms what does the spatial database for a gis system actually mean??
how do we use the GIS database system with a DGPS receiver?
this is uma from hyderabad.i am from malla reddy col .in my college tech is being organised is of two days program and people pls suggest me some some tech...