I've created a 2D array using this:
struct Cars (*ParkingLot)[FloorCount] = malloc(sizeof(struct Cars[FloorCount][10]));
I don't know if it matters but the FloorCount
is set to 1 for now, and struct Cars
is defined this way:
struct Cars
{
int ID;
char color[20];
char type[20];
};
Anyway, I'm trying to use this array in a function, and I can't access the values inside the array. For example, the next thing:
void CarIn (struct Cars *Lot[])
{
printf("%d", Lot[0][0].ID);
}
ParkingLot[0][0].ID=15;
CarIn(ParkingLot);
That's not what I wanna do, but it's the most basic function I can think of using the array, it will help me with the rest.
Edit:
Well, I've managed to print using the function, all I needed is to add &
before the Lot[0][0].ID
...
The other problem I have now is that this function doesn't seem to work at all, it always crash:
void CarIn (struct Cars *Lot[],struct Cars New)
{
Lot[0][0]=New;
return;
}