I am trying to allocate memory for a 3 by 5 2-dimensional array. When compiling this code, I receive this error in the cygwin terminal:
2darraymalloc.c: In function 'main':
2darraymalloc.c:7:9: warning: incompatible implicit declaration of built-in function 'malloc' a[i] = malloc(sizeof(int)*5);
#include <stdio.h>
void main() {
int *a[3], i, j;
for (i = 0 ; i < 3 ; i++) {
a[i] = malloc(sizeof(int) * 5);
}
for (i = 0 ; i < 3 ; i++) {
for (j = 0 ; j < 5 ; j++) {
a[i][j] = i + 2 * j;
}
}
printf("%d", *a[2]);
}