arr = malloc(sizeof(int)*row*col); 이부분이 애러가나요..
조심해
질문 제목 :arr = malloc(sizeof(int)*row*col); 이부분이 애러가나요..2차원 데이테 배열인대요arr = malloc(sizeof(int)*row*col); 이부분이 애러가나요..질문 내용 : #include stdio.h#include stdlib.h
int main(void){char fname[] = test.txt;int row=0,col=0;int i,j;file *f;int** arr;int t;int sum, max, min;
if ((f = fopen(fname, r)) == null){ printf(파일이 열리지 않습니다. \n); exit(1);};fscanf(f, %d, &row);fscanf(f, %d, &col);
arr = malloc(sizeof(int)*row*col);printf(%d %d\n, row, col);
for(i=0;irow;i++){ for(j=0;jcol;j++) { fscanf(f, %d, arr+(i*col+j)); }}
fclose(f);
max = 0;min = *(int *)arr;printf(각 행의 평균\n);for(i=0;irow;i++){ for(j=0,sum=0;jcol;j++) { t = *(int *)(arr+i*col+j); printf(%4d , t); sum += t;
if ( max t ) max = t; if ( min t ) min = t; } printf(평균 : %4d\n, sum/col);}
printf(최소값 : %4d, 최대값 : %4d\n, min, max);return 0;
}