The code below deletes the contents of game.answer
in the future and I can't figure out why.
This is the structure:
typedef struct
{
int guesses, guessesAllowed;
char* answer;
char max;
} GameState;
And this is my function to build a new structure:
GameState makeGame(int guessesAllowed, int numOfPositions, char max,
int seed)
{
GameState game;
char answer[9];
answer[0] = '\0';
game.guesses = 0;
game.guessesAllowed = guessesAllowed;
game.answer = answer;
game.max = max;
getAnswer(answer, numOfPositions, max, seed);
return game;
}
I figure it something to do with overriding memory it shouldn't?