I try to calloc 2d array and initial value of edge cell with 255, it work correctly but when I try to set dimension of array over than 12000*12000, VS2010 show Access violation writing location 0x00000000
my function of calloc 2d array
int **calloc_2d_int(int Rows, int Cols) {
int *data = (int *)calloc(Rows*Cols,sizeof(int));
int **array= (int **)calloc(Rows,sizeof(int*));
for (int i=0; i<Rows; i++)
array[i] = &(data[Cols*i]);
return array;
}
main function
int main(int argc, char* argv[]){
int i,j;
/*convert string to int*/
int row = atoi(argv[1]);
int column = atoi(argv[2]);
int T = atoi(argv[3]);
int** s[2];
s[0] = calloc_2d_int(row,column);
s[1] = calloc_2d_int(row,column);
for(i=0 ; i<row ; i++){
s[0][i][0] = 255; //error at this line
s[1][i][0] = 255;
s[0][i][column-1] = 255;
s[1][i][column-1] = 255;
}
for(i=0 ; i<column ; i++){
s[0][0][i] = 255;
s[1][0][i] = 255;
s[0][row-1][i] = 255;
s[1][row-1][i] = 255;
}
}
Thank you