Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!rpi!leah!bingvaxu!vu0310 From: vu0310@bingvaxu.cc.binghamton.edu (R. Kym Horsell) Newsgroups: comp.lang.c Subject: Re: ** help... Message-ID: <3871@bingvaxu.cc.binghamton.edu> Date: 21 Aug 90 02:32:28 GMT References: <2409@dsacg2.dsac.dla.mil> Reply-To: vu0310@bingvaxu.cc.binghamton.edu.cc.binghamton.edu (R. Kym Horsell) Organization: SUNY Binghamton, NY Lines: 34 In article <2409@dsacg2.dsac.dla.mil> nol2321@dsacg2.dsac.dla.mil (Jim Dunn) writes: \\\ >/* the problem is next */ > w1->array = malloc( xL * sizeof(int) ); >/* isn't the above line legal, or how can I allocate mem for the storage */ \\\ The first, minor, problem is that you haven't declared the prototype for malloc(). You'd better say extern char *malloc(); at the top or include the appropriate header (malloc.h is std but some PCs use alloc.h). This'll fix other problems when you try to change memory models. The main problem is that you didn't allocate the array, only the *rows* of the array. Better put w1->array = (int**)malloc(10 * sizeof(int*)); before the for-loop; otherwise there isn't anywhere for the ``row-of-rows'' to be stored! The final point: inside the for-loop you have said the array elements are int* -- i gather you really want to store ints in them so: w1->array[x] = (int*)malloc(10*sizeof(int)); Hope this helps, -Kym Horsell P.S. please don't edit the "Newsgroups" line.