Coder's Guild Mailing List

Re: Resizable arrays

Posted by Matthew Pratt on 1999-03-24

--- "Cohen / Joseph Peter (ISE)"
<j.cohen@xxxxxxx.xxxxxxxx.xxx.xx> wrote:
> Hi all,
>      Is it possible to have a plain old raw array
> that can be resized on
> the fly ?? (I imagine so)
> 
> and if so how would i declare such an array in c++.
> 

Look into malloc, realloc and free if using C.

char *buff = (char *)malloc(7);
buff[0]=0;
strcat( buff, "hello");

buff=realloc( buff, 14);

strcat(buff, " world.");
printf("%s\n", buff);
free(buff);


===
Matty                                       .
http://members.xoom.com/mattpratt/      _--_|\
mattpratt@xxxxx.xxx                    /      \
s3099239@xxxxxxx.xxx.xxx.xx            \_.--._/<--Canberra,
W2K - The other millenium bug.               v    Australia

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com