If either of the C Standard fgets() or fgetws() functions fail, the contents of the array being written is indeterminate. (see See undefined behavior 170.). It is necessary to reset the string to a known value to avoid errors on subsequent string manipulation functions.
...