For those who don’t know C, strings in C are just character arrays ending with a NUL-terminator ('\0'
).
In some of the auto-generated C code, the space for the NUL-terminator isn’t reserved. For example, in “Heat Detector”, I can see
char BOMB_DIR[2]; // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)
scanf("%s", BOMB_DIR);
It should be
char BOMB_DIR[3]; // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)
scanf("%s", BOMB_DIR);
so that Undefined Behavior won’t strike. I’ve seen this problem in another challenge as well.
Please fix it.