home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!elroy.jpl.nasa.gov!swrinde!cs.utexas.edu!asuvax!ennews!envmsa.eas.asu.edu!ptran
- From: ptran@envmsa.eas.asu.edu (Phi-Long Tran)
- Newsgroups: comp.lang.c
- Subject: Re: Array question....
- Keywords: help?
- Message-ID: <22JUL199218153390@envmsa.eas.asu.edu>
- Date: 23 Jul 92 01:15:00 GMT
- References: <14ks9uINNgmj@agate.berkeley.edu>
- Sender: news@ennews.eas.asu.edu (USENET News System)
- Distribution: ca
- Organization: Arizona State University, Tempe, AZ
- Lines: 25
- News-Software: VAX/VMS VNEWS 1.4-b1
-
- In article <14ks9uINNgmj@agate.berkeley.edu>,
- mdr@ocf.berkeley.edu (Mike Rogoff) writes...
-
- >Forgive my naivity, but could somebody help me with dynamically
- >allocating arrays? How would you go about it? If you just
- >malloc a bunch of space, can you reference it with array [] subscripts
- >and have it work?
-
- You want to declare a pointer to an array:
-
- MyType (*paryMyType)[MAX_ELEMENTQ];
-
- The above declares a pointer to an array of MAX_ELEMENTQ items. Variable
- paryMyType is like any other pointer that you can use with malloc, calloc,
- free, etc. Since paryMyType points to an array, "*paryMyType" is the
- array, thus you would say,
-
- (*paryMyType)[0] = /* Etcetera. */
-
- I think the word is spelled, "naivite".
-
- ---
- Phi-Long Tran
- ptran@asuvax.eas.asu.edu
- Arizona State University
-