delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/05/10:13:09

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: arrarys
Date: 5 Apr 2000 10:08:41 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 18
Message-ID: <8cf3b9$8gp$1@nets3.rz.RWTH-Aachen.DE>
References: <5ZtG4.648$OR3 DOT 8963 AT typhoon DOT nyroc DOT rr DOT com>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 954929321 8729 137.226.32.75 (5 Apr 2000 10:08:41 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 5 Apr 2000 10:08:41 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Bob <fubu36 AT stny DOT rr DOT com> wrote:
> if a array is delcared such as "int number[19];"
> is there anyway to later change it so that it keeps all of the original
> values but can hold an addition 1,5,or any addition numbers?

No. If you want it dynamic, don't use an array, use a pointer to 
malloc()ed storage:

	int *number = malloc(19*sizeof(int));

This allows you to realloc() this array, anytime.

Or, if you're doing C++, use one of the container classes of the STL.


-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019