Q:

getchar() and the enter button understanding how it really works

I have written the below function (while I was reading the Ritchie book on C) to get a single line from the command line. It does what it should do, and I understand how it works, but I wanted to dig a bit deeper.
int getLine(char arr[], int max) {
    int c, i;
    for (i = 0; i < max - 1 && (c = getchar())!= EOF && c!= '\n'; ++i) {
        arr[i] = c;
    }
    if(c == '\n') {
        arr[i] = c;
    }
    arr[i+1] = '\0';
    return i; /*length without '\n'*/
}

my question is about the loop, let's say we have a blank command line, and it is waiting for the user to enter something because the first getchar() is called in the loop, let's say then that the user entered the following:
h

My guess about what happens then, is that getchar() stores that 'h' in arr[] without the user actually pressing enter.
so if the user keeps typing:
hello

'h' 'e' 'l' 'l' and 'o' will be stored in arr[] without the user actually pressing enter and getchar will have been called a total of 6 times, the last one being after the 'o'. And then when the user presses enter, getchar() will store '\n' in arr[], am I right? Is this exactly how it works? So I guess the question is
does getchar() need enter to do what it does?
thanks

A:

getchar() does not return anything until you flush the input, for which you have to press Enter/Return or insert EOF, on a linux terminal that is achieved by pressing Ctrl+D and windows console Ctrl+Z will do it.

