Consider, for instance, a simple C program as follows:
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char arr[20];
gets(arr);
exit(EXIT_SUCCESS);
}
Ignore the deployment of scanf() for a moment. Nevertheless, the user enters the string and presses enter, which corresponds to the ASCII newline character (\n). Now, pray explain where the user-input gets stored initially. Is the string initially stored in a buffer and then passed to the character array "arr"? If so, it is passes serially or passed at once? If the aforementioned isn't applicable, is the string directly copied into the character array serially?
Moreover, on a tangential note, what precisely is a buffer in C? Where can I find resources apropos the functionality, description, and management of this specific buffer? Countless instances of my programs that invoke the scanf() and fgets() functions malfunction owing to a lingering newline character in the buffer. What does this imply? I was given to understand, much to my chagrin, that the program directly stores the data in the character array. Is this not the case? How does one manipulate and access the buffer?