For example, when I do scanf("%s",arg); : Terminal allows me to input text until a newline is encountered but it only stores up to the first space character inside the arg variable. Rest remains in buffer.
scanf("%c", arg); : In this case also it allows me to enter text into the terminal till I give a newline character, but only one is stored in arg while the rest remains in buffer.
scanf("%[^P]", arg); : In this case, I can enter text into the terminal even after giving it a newline character until I hit a line with 'P' in it and press enter key (newline character) and then transfers everything to the input buffer.
How is it determined how much data from the input stream is to be transferred to the input buffer at a time?
Assuming that arg is of the proper type.
My understanding seems to be fundamentally wrong here. If someone can please explain this stuff, I will be very grateful.
gnome-terminal-server-> ptmx -> kernel -> pts -> your process'sread()call -> libc buffering ->scanf()- Jonathon Reinhartkeyboard-electrical-contact -> keyboard-matrix-scanner -> usb-interface -> keyboard-driver -> gnome-terminal-server -> ...- and I've probably missed quite a few as well :-) - paxdiablo