I\'m learning C and I decided to make a text game as my learning project. So I\'m trying this primitive \"parser\" that reads a text file into a 2D array, but there\'s
You should have strdup'ed the contents read from the file. Replace the file reading block with this:
/* Reading file into array */
for (row = 0; row < ROWS; row++) {
for (col = 0; col < COLS; col++) {
if (fgets(charbuffer, 3, mapfile))
map[row][col] = strdup(charbuffer);
}
}
and don't forget to put this at the beginning of your code too:
#include