How it works...
In the program, the fgets function takes input from the standard input device and the maximum number of characters that will be read from the input device will be equal to the number of bytes allowed in the name variable of the user1 structure. As a result, even if the user enters a larger string, only the specified number of bytes from the input will be picked up; that is, only the first 10 characters in the input will be picked up and assigned to the name member of the user1 structure.
The fgets function appends the null character (\0) to the string, provided the number of characters entered is one less than the maximum length specified in the function. But for the string that is larger than the specified length, we need ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access