473,513 Members | 2,319 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to disable/enable displaying user input in console

Hi All,

I need a function that when user types a password in the console, the
password should be invisible (e.g. display nothing or display "*"
instead). Just as you can see when you login a machine.

How to implement this? Thanks!
Note: user is typing passord in the console.

Nov 30 '05 #1
4 7841
ki********@gmail.com wrote:
I need a function that when user types a password in the console, the
password should be invisible (e.g. display nothing or display "*"
instead). Just as you can see when you login a machine.

How to implement this? Thanks!
Note: user is typing passord in the console.


Your question is answered in the FAQ:

http://www.parashift.com/c++-faq-lit...html#faq-15.18

Best regards,

Tom

Nov 30 '05 #2
ki********@gmail.com wrote:
Hi All,

I need a function that when user types a password in the console, the
password should be invisible (e.g. display nothing or display "*"
instead). Just as you can see when you login a machine.

How to implement this? Thanks!
Note: user is typing passord in the console.


There is no standard C++ way to do that, because the C++ doesn't define a
console, but rather only an input stream (that may be connected to a
keyboard or not) and some output streams (that may be connected to a
display or not). You will need some platform-specific functions.
Maybe the (n)curses library can help you.

Nov 30 '05 #3
ki********@gmail.com wrote:
Hi All,

I need a function that when user types a password in the console, the
password should be invisible (e.g. display nothing or display "*"
instead). Just as you can see when you login a machine.

How to implement this? Thanks!
Note: user is typing passord in the console.

What consoles do is system dependent. You need to ask
in a group for your operating system (and possibly
windowing system) ... windows, unix, etc...

C++ doesn't address this.
Nov 30 '05 #4

<ki********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi All,

I need a function that when user types a password in the console, the
password should be invisible (e.g. display nothing or display "*"
instead). Just as you can see when you login a machine.

How to implement this? Thanks!
Note: user is typing passord in the console.


Use whatever OS specific call you have to read a key from the keyboard. It
is different for each OS. Then get a keypress, and print "*" to the screen.

char Input;
std::string Password;
while ( Input = FunctionToGetKeypress() != 13 ) // 13 is usually enter
{
Password += Input;
std::cout << "*";
cout.flush(); // May or may not be needed
}
std::cout << std::endl;

for Windows it's getch()
Not sure for linux.
check for your OS what function it is to get a single key press.
Dec 1 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9726
by: HolaGoogle | last post by:
Hi all, Can you please tell me what's wrong with my code??? i do have this database in wich i have to field.One is a "yes/no" field and another one is "number" field. To display the yes/no field...
2
6425
by: HolaGoogle | last post by:
Can you please tell me the right way to do this?? it's realy important! thanks in advance... Hi all, Can you please tell me what's wrong with my code??? i do have this database in wich i have...
12
8856
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
0
1109
by: dotnetkumar | last post by:
hi everybody, i am currently working with multipage and tabstrip controls. i want to disable the multipage and the controls inside it unless the user wants it to enable it. multipage.enable...
2
3210
by: rn5a | last post by:
In a shopping cart app, assume that a user has placed 4 orders (each order has a corresponding OrderID which will be unique). When he comes to MyCart.aspx, by default, the details of his last order...
0
1388
by: ArmyGeek | last post by:
Hey Guys, Im trying to figure out how to Disable a Button after a user clicks it, then Enable the Button if the user emptys a Text Box where the user can input information. I also want to...
2
6537
by: ArmyGeek | last post by:
Hey Guys, Im trying to figure out how to Disable a Button after a user clicks it, then Enable the Button if the user emptys a Text Box where the user can input information. I also want to...
56
3764
by: Deepan HTML | last post by:
Hi All, Currently i am working in a framed environment where i have divided the window as 20% and 80% and the 20% is used for navigation purpose and right frame for displaying the orignal content....
10
9062
by: sowmyati | last post by:
HI All, I am new to javascript. I have snippet wherein i am giving a brief note on what i am trying to do. In the below have a variable by name stuff. trying to reset the page. Part of the code...
0
7269
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7394
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7559
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.