I'm trying to program up a 2D dynamically allocated array for a map for a small game. Below is my code, I'm unsure why int* array[yCoord] is throwing up the error that it cannot be a variable length array, as the variable yCoord is assigned a specific value in the main function below. Any help greatly appreciated.
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include"random.h"
void createMap(int xCoord, int yCoord) {
    int i, j;
    xCoord += 2;
    yCoord += 2;
    int* array[yCoord];
    for (i = 0; i < yCoord; i++) {
        array[i] = (int*)malloc(xCoord * sizeof(int));
    }
    for (i = 0; i < yCoord; i++) {
        for (j = 0; j < xCoord; j++) {
            array[i][j] = 0;
        }
    }
}
int main(void) {
    int x, y;
    x = 5;
    y = 5;
    createMap(x, y);
    return 0;
}
 
     
    