Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!uwm.edu!rpi!zaphod.mps.ohio-state.edu!ncar!noao!arizona!naucse!jdc From: jdc@naucse.cse.nau.edu (John Campbell) Newsgroups: comp.lang.c Subject: Re: What's Wrong with this C Excert Message-ID: <2402@naucse.cse.nau.edu> Date: 3 Aug 90 14:54:34 GMT References: <34877@ut-emx.UUCP: Distribution: usa Organization: Northern Arizona University, Flagstaff AZ Lines: 40 From article <34877@ut-emx.UUCP:, by ezab066@ut-emx.UUCP (Albert Wu): : The following is part of an example I saw on p.301 of Byron S. : Gottfried's Schaum's Outline Series "Programming with C", copyrighted : 1990. It doesn't compile. Can anyone tell me what's wrong ? I am : a total beginner in C. Pls don't laugh. : : : #include : : #define MAXCOLS 30 : : main() : { : int (*a)[MAXCOLS],(*b)[MAXCOLS],(*c)[MAXCOLS]; : : ......... : : *a = (int*) malloc (rows * ncols * sizeof(nt)); : *b = (int*) malloc ( nrows * ncols * sizeof(int)); : *c =(int*) malloc ( nrows * ncols * sizeof(int)); : } Well, except for the syntax errors *a = (int*) malloc (nrows * ncols * sizeof(int)); /* I presume? */ and the need to define nrows and ncols, what is this supposed cdecl says: ``declare a as pointer to array 30 of int'' Now trying to malloc at this point sounds like a real mistake. I sure wish I knew what the author was thinking of here. Anyone else? (Karl?) -- John Campbell jdc@naucse.cse.nau.edu CAMPBELL@NAUVAX.bitnet unix? Sure send me a dozen, all different colors.