password masking

This is a discussion on password masking within the C Programming forums, part of the General Programming Boards category; I designed a program in C that I would like to use passwords for, but I can't seem to make ...

password masking

I designed a program in C that I would like to use passwords for, but I can't seem to make a function for masking the passwords. I figure that it has something to do with kbhit(); in <conio.h>, but I can't figure out how to properly use that function in this case. Anybody have an answer to this problem?

kbhit() shouldn't be necessary but you'd probably want to write your own fgets() using getch().
Read a character, then gotoxy(wherex()-1, wherey()) and putchar('*') and repeat until a newline is found.

That would depend on your OS and compiler.
Particularly, since you mention conio.h, are you programming for real DOS or merely using a DOS compiler in a win32 console, or perhaps even a proper 32 bit compiler in a win32 console.

well...

how do i do that? I dont really understand what you mean. Since getch() produces an int value, how am i supposed to get the characters in the password to use or display them? all ill have is a bunch of numbers!

You made an array of 1 char. The first and also last element of it is s[0] but in the code you used s[1].
The fix would be to change s to an array of 2 characters and change the if-statement comparson to use s[0] and have the s[1] = '\0'; come before the strcat(). And itoa() doesn't make much sense either. You probably just wanted s[0] = n;

Yes, it's a conio.h function. It allows you to move around in the console screen. wherex() and wherey() are also conio functions and will return the position the console cursor is for those axises.
Also, look at the edit. You don't have to use it.