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
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.
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.