할당 된 행렬에 값을 추가하려하지만 상수가 있고 Visual Studio에서 오류를 표시하고 실행을 중지합니다. 내 문제는 무엇일 수 있습니까? 함수가 int **
을 허용하기 때문에할당 된 행렬에 값을 입력 할 수 없습니다.
'#include <stdio.h>
#include <stdlib.h>
void scanMath(int,int,int);
void main()
{
int i,n,m,**arr;
printf("enter the size of the rows\n");
scanf("%d",&n);
printf("enter the size of the coloms\n");
scanf("%d",&m);
arr=(int**)malloc(n*sizeof(int*));
for (i=0;i<n;i++)
{
arr[i]=(int*)malloc(m*sizeof(int));
}
scanMath(arr[n][m],n,m);
free(arr);
}
void scanMath(int arr,int R,int C)
{
int i,j;
for (i=0; i<R; i++)
{
for (j=0; j<C; j++)
{
scanf("%d", &arr[i][j]);
}
}
}
'
컴파일러에서 제공 한 오류 메시지를 읽으려고 했습니까? 그렇게하고, 이해하지 못하면 여기에 게시하십시오. – interjay
포인터에 대해 더 많이 읽는 것이 좋습니다. – phoxis