You need to use malloc() for that and then there's really no simple way to do it as a 2D array. You could try something like this:
Code:
itsme@itsme:~/C$ cat dynarray.c
#include <stdio.h>
#include <stdlib.h>
#define TABLE(y, x) (*((table) + (x) + (y) * (size)))
int main(void)
{
char buf[10];
int *table;
int size;
do
{
printf("Array size (1-9999)? ");
fflush(stdout);
fgets(buf, sizeof(buf), stdin);
size = atoi(buf);
} while(size < 1 || size > 9999);
if(!(table = malloc(sizeof(int) * size * size)))
{
puts("Memory allocation error!");
exit(EXIT_FAILURE);
}
TABLE(0, 0) = 3;
printf("table[0][0] = %d\n", TABLE(0, 0));
free(table);
return EXIT_SUCCESS;
}
itsme@itsme:~/C$ ./dynarray
Array size (1-9999)? 10
table[0][0] = 3
itsme@itsme:~/C$