| delorie.com/archives/browse.cgi | search |
| From: | "Ilari Kaartinen" <ililka AT mantta DOT fi> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: arrarys |
| Date: | Thu, 6 Apr 2000 17:33:47 +0300 |
| Organization: | Tampere Telephone Plc |
| Lines: | 36 |
| Message-ID: | <8ci6hc$di5$1@news.koti.tpo.fi> |
| References: | <5ZtG4.648$OR3 DOT 8963 AT typhoon DOT nyroc DOT rr DOT com> |
| NNTP-Posting-Host: | s.kurvi.phpoint.net |
| X-Trace: | news.koti.tpo.fi 955030892 13893 212.246.13.20 (6 Apr 2000 14:21:32 GMT) |
| X-Complaints-To: | abuse AT tpo DOT fi |
| NNTP-Posting-Date: | 6 Apr 2000 14:21:32 GMT |
| X-Priority: | 3 |
| X-MSMail-Priority: | Normal |
| X-Newsreader: | Microsoft Outlook Express 5.00.2014.211 |
| X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2014.211 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
You didn't give enough information to answer this question.
So, I assume that you are using C.
Bob <fubu36 AT stny DOT rr DOT com> wrote in message
news:5ZtG4.648$OR3 DOT 8963 AT typhoon DOT nyroc DOT rr DOT com...
> 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?
>
>
/* clip clip */
#include <stdio.h>
#define SIZEOFARRAY 19
#define ADDME 5
int main(void)
{
int* array = (int*)malloc(sizeof(int)*SIZEOFARRAY);
if(array == NULL)
return 1;
/* this is what you wanted */
array = (int*)realloc(array,sizeof(int)*(SIZEOFARRAY+ADDME));
free(array);
return 0;
}
/* clip clip */
--
- Ilari
http://www.mantta.fi/~ililka/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |