From: "John T. Williams" <jtwilliams@vt.edu>
To: linux-c-programming <linux-c-programming@vger.kernel.org>
Subject: I'm really starting to dislike stdio
Date: Thu, 19 Jun 2003 03:33:16 -0400 [thread overview]
Message-ID: <004001c33635$21f3d3a0$e764a8c0@fesnel.noip.org> (raw)
In-Reply-To: 003c01c335c7$a7f437b0$3d6405d5@carlos
I really appricated the help with the progress bar.
I have another problem
I am trying to read in a password from the stdin, but I don't want it to
display to the screen as the person types it in.
I either like to mock su, and take input w/o any output, or output a * for
each typed character, and I cannot figure out how to get this to work
I've tried
_____________________
read(1, &tmpch, 1);
while(tmpch != '\n') {
memset(prog, '*', stars);
printf("\rPassword: %-20s ", prog );
stars++;
buff[loop] = tmpch;
loop++;
read(1, &tmpch, 1);
}
read(1, &tmpch, 1);
while(tmpch != '\n') {
memset(prog, '*', stars);
printf("\rPassword: %-20s ", prog );
stars++;
buff[loop] = tmpch;
loop++;
read(1, &tmpch, 1);
}
--------------------------
I've tried
____________________
tmpch = getchar();
while(tmpch != '\n') {
memset(prog, '*', stars)
printf("\rPassword: %-20s ", prog );
stars++;
buff[loop] = tmpch;
loop++;
tmpch = getchar();
}
and I tried getc from the curses library.
The problem with all of these is that they only actually do the read part
after I've hit the <enter> key. I want it to process each character as it
is typed. Anyone who has any ideas or can tell me a better way to read
characters w/o displaying it to the screen and I'd be greatful.
next prev parent reply other threads:[~2003-06-19 7:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-18 9:58 stdio John T. Williams
2003-06-18 12:02 ` stdio Jan-Benedict Glaw
2003-06-18 12:17 ` stdio Luciano Moreira - igLnx
2003-06-18 13:04 ` stdio Stephen Satchell
2003-06-18 17:45 ` stdio Glynn Clements
2003-06-18 18:30 ` stdio Chris Nanakos
2003-06-19 7:33 ` John T. Williams [this message]
2003-06-19 11:26 ` I'm really starting to dislike stdio Jan-Benedict Glaw
2003-06-19 17:39 ` Glynn Clements
2003-06-19 12:56 ` Andrés Roldán
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='004001c33635$21f3d3a0$e764a8c0@fesnel.noip.org' \
--to=jtwilliams@vt.edu \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).