file handling

is there any way to write a number to a file simultaneously receiving it from user without being pressed enter...
i want the number to be entered in a file and at the same time as the user enters the numbers,they should be entered into a file.i am trying the following code...but that doesnt seem to work
FILE *fp;
char c;

plz help me with this thing..
i am using this because i want to store two very large numbers in a file
Last edited on
As far as I know, it's not possible.

The only way I can think of is to trick the IO stream to send each char typed to the file some how faking a carriage return, which doesn't make any sense to me right now.

I suspect, you'll have to write your own IO stream, or find one that does that already.
Yes, just use unbuffered I/O, but that requires using operating system specific APIs.

Maybe ncurses library can do what you want in a portable manner.
Well, you could do it by capturing keystrokes, but the way I would suggest is non-standard and non portable, using getch() or similar.

But, what if the user makes an error and wants to press backspace or correct some mistyped value? You could handle that too, but really, I'd recommend getting the input as a string, and after that, write the string to the file.

Topic archived. No new replies allowed.