As suggested by a book of "Gottfried", I tried to input an array and display the contents of array in matrix form :
#include<stdio.h>
#define row 2
#define col 3
int main(){
int (*a)[col];
int i,j;
for(i=0;i<row;i++){
for(j=0;i<col;j++){
printf("Enter a(%d,%d)",i,j);
scanf("%d",(*(a+i)+j));
}
}
return 0;
}
I get the following output after inputting an element :
Segmentation fault (core dumped)
What is the problem in the code? Was it working in previous version of GCC so the writer wrote it down? What is the correct way to solve the problem with the same level of simplicity?