Well I got this issue and I don't get why? If someone could explain I'm just trying to learn C lmao
I don't even have a clue of where I'm supposed to let it implicitly declare this function as something else than a struct Map*, if someone can explain I would be gratefull.
#include <stdio.h>
#include <stdlib.h>
struct Map{
unsigned int DimX;
unsigned int DimY;
char** Map;
};
void main(){
printf("Hello world, at least it compiled\n");
unsigned int DimX = 10;
unsigned int DimY = 10;
struct Map* M = InitMap(DimX, DimY);
PrintMap(M);
}
//Initialise the map with 0 everywhere
struct Map* InitMap(unsigned int DimX,unsigned int DimY){
struct Map* M;
M = malloc(sizeof(struct Map));
M->DimX = DimX;
M->DimY = DimY;
M->Map = malloc(sizeof(char*)*DimX);
for(int i = 0; i < DimX; i++){
M->Map[i] = malloc(sizeof(char)*DimY);
for(int j = 0; j < DimY; j++){
M->Map[i][j] = 0;
}
}
return M;
}
Well I did try to cast it explicitely as a struct Map* but it didn't worked...
I just want it to intialize the matrix of a DimX * DimY with 0 for the moment...