HI please help me here. Segmentation fault always occur in my program. when malloc is in main, it is running, but when i put malloc in another function, segmentation fault occurs. here is my code
Code:#include<stdio.h> #include<malloc.h> void malloc_array(int **array;int row;int col){ int i; array=(int**)malloc(row*sizeof(int*)); for(i=0;i<row;i++){ array[i]=(int*)malloc(col*sizeof(int); } } main(){ int **array, row=5, col=7; malloc_array(array,row,col); . . . }



3Likes
LinkBack URL
About LinkBacks



