How did you come by this observation? To become good at programming, you should be able to test such ideas with practice snippets of code. For example, I figured out the answer to your question with this:
Code:
// quick and dirty example
#include <stdio.h>
#define MAX_LEN 10
int main(void)
{
char str_input[MAX_LEN];
int left_over = 0;
// read user input, 9 characters max
printf("Enter string: ");
fgets(str_input,MAX_LEN,stdin);
// quick and sloppy null termination at the end of the character array
str_input[MAX_LEN-1] = '\0';
// at runtime, we will enter 15 characters, followed by enter (newline)
// now we'll print our string:
printf("\nString: %s\n\n",str_input);
// ... and print out anything left over in the input buffer, up to a newline
printf("Left over characters: ");
while((left_over = getchar()) != '\n')
printf("%c",left_over);
printf("\n\n");
return 0;
}
And here is my output:
Code:
Enter string: ABCDEFGHIJLKMNO
String: ABCDEFGHI
Left over characters: JLKMNO
Therefore, we see that when the data in the input buffer exceeds the limit of "fgets()", the rest of the data continues to sit in the buffer.