From: "Vermin" Newsgroups: comp.os.msdos.djgpp References: <8mueij$hd7$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> Subject: ...but Lines: 53 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Message-ID: Date: Thu, 10 Aug 2000 22:38:06 +0200 NNTP-Posting-Host: 130.67.73.247 X-Complaints-To: news-abuse AT online DOT no X-Trace: news1.online.no 965939445 130.67.73.247 (Thu, 10 Aug 2000 22:30:45 MET DST) NNTP-Posting-Date: Thu, 10 Aug 2000 22:30:45 MET DST Organization: Telenor Online Public Access To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com but is it possible to have an array (or a pointer to an array) which doesn't have a a given size (or doesn't really exist) until you define it by making space for it in the mem... some pseudo code: procedure proc1(pointer pp){ pp (points to) new array[arraySize]; } main(){ pointer p1; call proc1(p1); } "Hans-Bernhard Broeker" wrote in message news:8mueij$hd7$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE... > 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.