In Ex24 we use fgets
like this:
fgets(you.first_name, MAX_DATA - 1, stdin);
Reading the man description of fgets
it mentions:
fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s.
With that in mind I found no obvious change in behavior by issuing MAX_DATA
without the - 1
like this:
fgets(you.first_name, MAX_DATA, stdin);
So for all intents n purposes this seems like valid code because fgets itself stops one less than size characters
. So would the former code be prematurely ending the input scan one extra character early and the latter being more accurate? Or is there a valid purpose for this extra decrement here?