gets() reads in a line, replacing the newline with the terminating Nul byte, and places it in the char array passed, without ANY error checking if the array is large enough to hold it! gets() will possibly overwrite space beyond the end of the array, crashing the program if you are lucky! For that reason, it has been REMOVED from the Standard Library, and fgets() has been recommended as the replacement!
fgets() will also attempt to read in a string, and place it in the array provided, up to one char short of the length of the array, which should be passed as the second argument to fgets(), allowing room for the terminating Nul byte! If the string is longer that the size passed minus one, the partial string will be terminated, and multiple reads will be needed to input the entire line. When the full string, or remaining portion of a long string has been read in, the newline will be at the end of the string in the array. You will need to remove the newline yourself.
Please study the manpage for
fgets()!!!
You DO NOT need to know the size of the "buffer" internal to fgets()!!! You only need to worry about the the size of the array you pass to fgets()!!! fgets() will allocate and handle the use of the "internal buffer"!!!!!!!! As I said above, if the array YOU create and pass to fgets(), is shorter that the length of the string input, you will need multiple calls to fgets() to read in the entire length of the string. The size of the "Internal buffer" is COMPLETELY IRRELEVANT to this process!!! Programmers since C was invented in 1978 have been using fgets() without needing to worry about the internals of fgets()!!!
fgets(), fread(), etc... are "Buffered I/O" as apposed to read, etc... whitch is not buffered.
Line buffered means that fgets(), getchar(), etc... wait until the newline has been pressed or input, before reading in the data.
fflush() is a function to force the output of printf(), fprinf(), and other OUTPUT functions, out to the screen or disk file. fflush() should NEVER be used with an INPUT buffer!!! There are methods to "flush" the input buffer if needed.