By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,330 Members | 1,438 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,330 IT Pros & Developers. It's quick & easy.

password input for command prompt based application

P: 1
pltform solaris
language C++
compiler g++

i'm wrting a chat system
my application is a command promt based application
i just can't figure out how to get the password from the user without showing what the user is typing on the screen

i want stars to be shown on the screen instead of the characters, the user types in
Feb 20 '07 #1
Share this Question
Share on Google+
3 Replies


P: 96
-- code removed --

try the above code....
Passwd is a case sensitive.....
Feb 20 '07 #2

Banfa
Expert Mod 5K+
P: 8,916
Your problem is that getchar(...) or fgetgetc(...) or getc(...) all echo the character that is input, however these are the only standard library functions for character input.

As far as I am aware all standard library functions always echo the input data so you need a non-standard library function. As the name non-standard suggests functions of this nature are platform dependent and just because it exists on 1 system doesn't mean it exists on another.

2 functions that exist on a few systems are

getch() or _getch()

and

getche() or _getche()

I suggest you search you header files or platform documentation to see if they exist. The first gets a character without echo and the second gets a character and echos it to the screen (neither require that enter is pressed).

Alternitively you could look into using the Curses library which while it is not a standard liberary is supported by many platforms.
Feb 20 '07 #3

AdrianH
Expert 100+
P: 1,251
The ncurses library is a fairly standard library and widely supported.


Adrian
Feb 20 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.