c - What does enter key mean in linux terminal? -


i've got simple c function below:

#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) {     int c;     while ((c = getchar()) != eof)         putchar(c);     return exit_success; } 


use gcc on linux os terminal test it. result is:

d d e e f f 5 5 56 56 


want know:

1. why every time press enter key, terminal repeats character typed?

2. why put 2 characters (56), , works too, how work?

3. why enter key makes terminal repeat, not other keys?

4. pressing enter key mean in linux terminal or c program this?

terminal input managed through kernel specific object known "tty". tty buffers input before (by default) delivering data process. useful because lets (as user) correct command line before sending processes. tty buffering in line-mode, meaning input data delivered either if buffer full or newline inputed.

so when type single char, char not available process, inside tty buffer. type new line , both available process able read first one, pushes output reads newline , pushes output.

tty's behaviour can changed, see command stty example. encourage read "posix terminals".


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -