+ 3
Is scanf () function automatically allocate space for null terminator like fgets()? In C
|| Otherwise we have to manually allocate a space for null terminator in scanf() while handling with strings....? https://code.sololearn.com/cC9K438PtS1C/?ref=app
1 Answer
+ 5
Neither scanf() nor fgets() allocate space for input strings and NULL terminators. The caller must provide pre-allocated memory space for string input, and yes, be certain to have a spare byte to accept the terminating NULL when calling either function.