How are we supposed to 'make it work' when you haven't said what it's supposed to do to begin with.
There's this
Code:
$ gcc -Wall foo.c
foo.c: In function ‘main’:
foo.c:17:20: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long int’ [-Wformat=]
printf("a[%d][%d] = %d\n", i, j, a[i][j]);
^
Did you change ALL the <= 15?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
long** a = malloc(15*sizeof(long*));
for ( int i = 0 ; i < 15; i++ ) {
a[i] = malloc(15*sizeof(long));
for ( int j = 0 ; j < 15 ; j++ ) {
a[i][j] = 0;
}
}
for ( int i = 0 ; i < 15; i++ ) {
for ( int j = 0 ; j < 15 ; j++ ) {
printf("a[%d][%d] = %ld\n", i, j, a[i][j]);
}
}
//rest of the program
for ( int i = 0 ; i < 15; i++ )
free(a[i]);
free(a);
return 0;
}