내 프로그램은 런타임에 2 차원 배열에 메모리를 할당 한 다음 요소를 가져 와서 표시합니다. 내 prog 누군가가 그것을 식별하는 데 도움이 될 수있는 몇 가지 예외를 던지고 있습니까? 알록 올바르게 문제를 추측으로프로그램에 unknow 예외가 발생했습니다.
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
int main()
{
int i,j,row, col;
int *ptr;
printf("enter size of row and col\n");
scanf("%d%d",&row,&col);
ptr = (int *)malloc(row*col*sizeof(int));
if(ptr==NULL)
{
printf("stderr, not able to allocate memory");
exit(1);
}
else
{
printf("enter the element");
for(i=0; i<row;i++)
for(j=0;j<col;j++)
{
scanf("%d",ptr[i+j]);
}
for(i=0; i<row;i++)
{
for(j=0;j<col;j++)
printf("%d ",ptr[i+j]);
printf("\n");
}
}
}
'scanf ("% d", ptr [i + j]);'이 작업은 무엇입니까? –
실제 오류를 게시하십시오. – JasonD
디버거에서 실행하고 실패한 곳을 확인하십시오. – NPE