callocing 2D array

Il-hyung Cho ich at unix.cis.pitt.edu
Tue Apr 30 12:04:26 AEST 1991


Hello, guys.
I'm not quite good at C, but I hope some of you could help my problem.
I'm trying to implement 2D array whose size is not known until run time.
The way I tried was like follows:

---------------------------------------------------------------
typedef int **ary;
main()
{
	int **i;

	i = (ary) calloc(25, sizeof(int));
	i[0[0] = 1;	/* Segmentation falut */
}

------------------------------------------------------------------
As indicated, the array cannot be assigned any value.
How do I solve the problem?

I'll really appreciate any of your help.
Thanks.

PS> If you are willing to help me, please email me.
    Thanks a bunch.



More information about the Comp.lang.c mailing list