I just want to ask..
How could I make the input (password) invisible?

Recommended Answers

All 6 Replies

Are you talking about a console program? If you are then you'll have to state which operating system.

Haven't heard of that yet..
I've been trying to use string function, but the problem the problem states that,, as I enter the password, it must be invisible already...

How could I make the input (password) invisible?

You probably don't really want to make it invisible because that's not as user-friendly as it could be. A generally accepted way to accept passwords is by masking the characters:

char *get_password(char buf[], size_t n)
    size_t i;
    for (i = 0; i < n - 1; i++) {
        int ch = raw_keypress(NO_ECHO);
        if (ch == '\r') {
        buf[i] = (char)ch;
    buf[i] = '\0';
    return buf;

The key point in both this an invisible input is being able to accept character input without echo. Standard C doesn't support this behavior, so you'll need to figure out how to do it on your implementation. For example, compilers that support <conio.h> will typically have a getch() function that reads raw keyboard input without echo.

We're just talking about the simpler codes..that's why I don't get it much ..
Thanks anyway ..
I'll try another one ..

Follow up question about what you have mentioned.
I've researched, and I've seen "CONSOLE" program etc.
what does that mean?

Be a part of the DaniWeb community

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