BUG : scrabble, auto-generated Code, C version, fgets

In the auto-gererated codes for language C:

char LETTERS[7]; fgets(LETTERS,7,stdin);

since C strings are null-terminated, one last character must be reserved for the ending '\0'. Thus function fgets only reads 7-1 character from the input stream and store it into LETTERS. as a result, the last character is not in LETTERS. solution: change both 7 to 8, or better, (7+1);

p.s. I think this is a general problem with the C codes, just that in other cases its not lethal.

1 Like

Thanks @mashikin, it’s fixed on this puzzle.