Hi
Recently I started programming C (not C++) in borland 4.5 at school. Now my teammate and I have to make a small game. Therefor I will use an two-dimensional array, the field (a table, rows and colmnes). This two-dimensional array holds chars ("X", "|", "J", "-" and " ").
I would like to have an option where the player can change the lengte and width of the field. Thats where dynamic allocation comes in.
Here is the part of the function in my code that gives me troubles, its about malloc and it compiles but gives an error when it runs: "Stack Fault".
void teken_veld() {
char* tab_veld[80][80];
int y, x;
for(y=0;y<lengte;y++){
for(x=0;x<breedte;x++){
tab_veld[y][x]=malloc(lengte*sizeof(char));
strcpy(tab_veld[y][x], " ");
}
}
free(tab_veld[y][x]);
strcpy(tab_veld[0][posvisser], "X");
strcpy(tab_veld[posvishaak][posvisser], "J");
...
}
I would realy appreciate if somewanne could help me out.
Greetings
Kevin