[ CnUnix ] in KIDS 글 쓴 이(By): yamang (<홀로서기>) 날 짜 (Date): 2004년 6월 8일 화요일 오후 12시 19분 47초 제 목(Title): Re: [Q] malloc and array n1,n2,n3갯수로 이루어진 배열을 리턴하는 코드입니다. /* ========= Make a n1,n2 and n3 cubic matrix =====================*/ double ***cube_mat(n1,n2,n3) int n1,n2,n3; { int i,j; double ***m; m = (double***) calloc(n1, sizeof(double**)); if( m == (double ***) NULL) { printf("Out of Memory\007 at make_mat \n" ); exit(0); } for(i=0; i<n1; i++){ m[i] = (double**) calloc(n2, sizeof(double*)); if( m[i] == (double **) NULL) { printf("Out of Memory\007 at make_mat \n" ); exit(0); } } for(i=0; i<n1; i++) for(j=0; j<n2; j++){ m[i][j] = (double*) calloc(n3, sizeof(double)); if( m[i][j] == (double *) NULL) { printf("Out of Memory\007 at make_mat \n" ); exit(0); } } return (double***)m; } |