473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Input/Output function

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
5 4034
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
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
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
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


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Florian Wilhelm | last post by:
I have some easy questions, but I cant figure them out: I want to read exactly one char from stdin, there should be no need to hit enter. import sys print "Input: (y/N) ", input =...
1
by: Luke Wu | last post by:
I have been using the getline function from K&R2 for simple character input. The prototype is int getline(char *s, int limit); /* returns 0 to signal EOF */ This function simply calls...
8
by: FS Liu | last post by:
Hi, I am writing ATL Service application (XML Web service) in VS.NET C++. Are there any sample programs that accept XML as input and XML as output in the web service? Thank you very much.
8
by: Radith | last post by:
Hi All, I have a number guessing game in which users try to guess a random number. Obviously, input is required of type int. BUT, when a user inputs a string the program will result in an...
8
by: ais523 | last post by:
I use this function that I wrote for inputting strings. It's meant to return a pointer to mallocated memory holding one input string, or 0 on error. (Personally, I prefer to use 0 to NULL when...
2
by: jackson2005 | last post by:
OK, I need to do three different things. On the ONLOAD event I would like a popup box to open. In this popup box I need two text boxes. One for the UserName and one for the BillingTo name. ...
1
by: S. David Kyle | last post by:
I am having a weird issue when I generate an input Html tag from a Xsl transformation. When the trasform is executed on the xsl below, the <inputtag has the closing slash removed in the first...
0
by: Anonieko | last post by:
Are there any javascript codes there? Answer: Yes On the PageLoad event call InitialClientControsl as follows /// <summary> /// This will add client-side event handlers for most of the...
3
by: John Williams | last post by:
I'm writing a stagenography program to experiment with how it works. The algorithm I'm using appears to be producing the correct result...however I'm struggling with the file input. I never...
13
by: cront | last post by:
I have a problem to work on: we will ask user to input anything and we will put that back onto the standard output with all set of brackets removed. We will not remove any single bracket e.g. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.