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

Input/Output function

P: n/a
Don't you know the function that can make input without writing
charecters on the output (under UNIX). I mean something like, when you
write Password on Unix, you write and the charecters are not seen, but
there are written in the buffer. Does anyone know any Unix library
(maybe a function that can do it). There is no in stdio.h as I found
out :(
Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
maths_fan wrote:
Don't you know the function that can make input without writing
charecters on the output (under UNIX). I mean something like, when you
write Password on Unix, you write and the charecters are not seen, but
there are written in the buffer. Does anyone know any Unix library
(maybe a function that can do it). There is no in stdio.h as I found
out :(

This is probably off-topic to this newsgroup, but here's my 2c:
Two possible solutions: Have a look at the 'curses' package or the
relevant ioctl calls for the tty (or pty) special file connecting to
your terminal/window. The former is simpler than the latter.

Nov 13 '05 #2

P: n/a
ma*******@mail.ru (maths_fan) wrote:
Don't you know the function that can make input without writing
charecters on the output (under UNIX). I mean something like, when you
write Password on Unix, you write and the charecters are not seen, but
there are written in the buffer. Does anyone know any Unix library
(maybe a function that can do it). There is no in stdio.h as I found
out :(


<http://www.eskimo.com/~scs/C-faq/q19.1.html>.

HTH; HAND.

Richard
Nov 13 '05 #3

P: n/a
In <c1*************************@posting.google.com> ma*******@mail.ru (maths_fan) writes:
Don't you know the function that can make input without writing
charecters on the output (under UNIX). I mean something like, when you
write Password on Unix, you write and the charecters are not seen, but
there are written in the buffer. Does anyone know any Unix library
(maybe a function that can do it). There is no in stdio.h as I found
out :(


getchar() works just fine, once you have disabled echoing, e.g. with
the stty command (that you can execute from your program with a
system() call).

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #4

P: n/a
hi,
Don't you know the function that can make input without writing
<snip> your terminal/window. The former is simpler than the latter.

http://www.faqs.org/faqs/unix-faq/programmer/faq/ read question 3.1

WBR SK
Nov 13 '05 #5

P: n/a


maths_fan wrote:
Don't you know the function that can make input without writing
charecters on the output (under UNIX). I mean something like, when you
write Password on Unix, you write and the charecters are not seen, but
there are written in the buffer. Does anyone know any Unix library
(maybe a function that can do it). There is no in stdio.h as I found
out :(


Someone posted this a while back:

#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <string.h>

static struct termios stored_settings;

void echo_off(void)
{
struct termios new_settings;
tcgetattr(0,&stored_settings);
new_settings = stored_settings;
new_settings.c_lflag &= (~ECHO);
tcsetattr(0,TCSANOW,&new_settings);
return;
}

void echo_on(void)
{
tcsetattr(0,TCSANOW,&stored_settings);
return;
}

int main()
{
int ch;
int ph = '*';
echo_off();
while((ch = getchar()) != EOF)
putchar(ph);
echo_on();

return 0;
}

Unfortunately I don't recall who to credit for it.

Regards,

Ed.

Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.