From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: a bit about arrays... Date: 10 Aug 2000 14:34:59 GMT Organization: Aachen University of Technology (RWTH) Lines: 32 Message-ID: <8mueij$hd7$1@nets3.rz.RWTH-Aachen.DE> References: NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 965918099 17831 137.226.32.75 (10 Aug 2000 14:34:59 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 10 Aug 2000 14:34:59 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Vermin wrote: > <1> > What's the difference between > char anArray[100]; > and > char *anArray; > anArray = new (char)[100]; Place of storage, and lifetime of the array. The first creates an array that lives on the stack, until you leave the block the definition is found in (or in a global data segment until program termination, if it's at file scope), the second creates a block that exists until you delete[] it, and a pointer to it with a certain lifetime. > <2> How can I pass an array with undefined size to a procedure, and > get the procedure to set the array size (C++)?? You can't. Array size isn't modifiable a posteriori. You can only change the size of "new"ed arrays, and that only by delete[]ing them and "new"ing a new one. If you need a truly variable-sized array, look up the 'vector' template. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.