3
Contributors
6
Replies
9
Views
5 Years
Discussion Span
Last Post by Narue
0

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

0

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') {
            putchar('\n');
            break;
        }
        
        buf[i] = (char)ch;
        putchar('*');
    }
    
    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.

0

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

0

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

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.