Well, I am trying to figure out how I can create a matrix with user-defined dimensions. I do need something like that since I am programming some numerical methods that involve matrices. So, I made this code as a test:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <alloc.h>
void main ()
{
int *table=NULL,n,i;
scanf("%d",&n);
table=(int *) calloc(n,sizeof(n));
printf ("Input matrix items:\n");
for (i=0;i<n;i++) {
scanf("%d",table[i]);
}
for (i=0;i<n;i++) {
printf ("%d,",table[i]);
}
}
Still it does not work and the output I get is: "0,0,...,0,Null pointer assignment." As I am not very familiar with pointers I suppose that is the problem.