Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,047 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,523 people online right now. Registration is fast and FREE... Join Now!




Get a user inputted string without displaying it?

 
Reply to this topicStart new topic

Get a user inputted string without displaying it?

kramed
31 Jul, 2008 - 08:37 PM
Post #1

New D.I.C Head
*

Joined: 3 Oct, 2006
Posts: 21


My Contributions
Hi there,

I was hoping to find out what I need to look for in order to retrieve a user inputted string without displaying the input to the monitor, exactly like a unix login screen for the password entry.

Thanks
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Get A User Inputted String Without Displaying It?
31 Jul, 2008 - 09:11 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,435



Thanked: 64 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
Guessing that you are doing this on Linux : http://linux.about.com/library/cmd/blcmdl3_tcsetattr.htm
User is offlineProfile CardPM
+Quote Post

kramed
RE: Get A User Inputted String Without Displaying It?
3 Aug, 2008 - 07:31 PM
Post #3

New D.I.C Head
*

Joined: 3 Oct, 2006
Posts: 21


My Contributions
Actually Solaris. I took a look at the header you suggested and read the whole Terminal IO chapter in APUE2 but I am still not sure what I am looking for. Do I need to change a flag or is it much more complicated than that?
User is offlineProfile CardPM
+Quote Post

kramed
RE: Get A User Inputted String Without Displaying It?
4 Aug, 2008 - 06:29 AM
Post #4

New D.I.C Head
*

Joined: 3 Oct, 2006
Posts: 21


My Contributions
CODE
#include <sys/termios.h>

int echo_on()
{
    struct termios tt_struct;

    if (tcgetattr(0, &tt_struct) < 0)
        return -1;

    tt_struct.c_lflag |= ECHO;
    return tcsetattr(0, TCSANOW, &tt_struct);
}

int echo_off()
{
    struct termios tt_struct;

    if (tcgetattr(0, &tt_struct) < 0)
        return -1;

    tt_struct.c_lflag &= ~ECHO;
    return tcsetattr(0, TCSANOW, &tt_struct);
}

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 05:11PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month