So, i'm tring to allocate memory to insert file names in it. I have my struct Estado defined like this:
typedef struct estado{
char modo;
char jogador;
char matriz[8][8];
int pretas;
int brancas;
char *nome[10];
int current;
} Estado;
I tried doing this:
Estado insereFicheiro(Estado estado , char* nome){
estado.nome[estado.current] = malloc(sizeof(char*));
estado.nome[estado.current++] = nome;
return estado;
}
What am i doing wrong ?
estado.nome[estado.current] = malloc(20 * sizeof(char)for example. And for assignment usestrcpy.