Given input in the stdin buffer, when successive calls to getchar() are performed, does the pointer move along the memory address of the stdin buffer, allowing getchar() to retrieve the value at each address? If so, once they have been retrieved are the values removed and the pointer then incremented?
Generally my understanding of getchar() in a loop follows this logic:
- getchar() called
- stdin buffer checked for input
- If stdin buffer empty, getchar() sleeps
- user enters input and awakens get char()
- stdin buffer checked again for input
- stdin buffer not empty
- getchar() retrieves value at address at the start of the stdin buffer
- value at address removed from stdin buffer, pointer incremented
- subsequent calls repeat steps 7-8 until EOF encountered
A similar question was asked before on stackoverflow but I had trouble understanding the responses.