http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

TheGrumpyProgrammer



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic arrays



dynamic arrays can be created easily in both C and C++ using the malloc() or
new

e.g.

char *ptrArray = NULL;

// for c++, use new to dynamically allocate at run-time a char array of 10
elements
ptrArray = new char[10];

// for C, use malloc() to allocate at runtime a char array of 10 elements
ptrArray = (char*) malloc(sizeof(char)*10);

also remember to clean up the dynamically allocated memory using delete
(c++), or free (c).


Ken

----- Original Message -----
From: "Mike Main" <anime6@earthlink.net>
To: <gameprogrammer@gameprogrammer.com>
Sent: Friday, September 22, 2000 7:42 PM
Subject: Re: Dynamic arrays


> You can change the size of a linked list.  Maybe it isn't clear to me what
> the application is.
> ----- Original Message -----
> From: <dakline@vassar.edu>
> To: <gameprogrammer@gameprogrammer.com>
> Sent: Friday, September 22, 2000 10:17 PM
> Subject: Re: Dynamic arrays
>
>
> > Linked lists have the same problem as vectors, except they have even
more
> > overhead. I'm thinking of situations where I don't need that much power
> and
> > definately anything that size/memory intensive.
> >
> > >*Cough cough* LINKED LISTS *Cough Hack!*
> > >----- Original Message -----
> > >From: <dakline@vassar.edu>
> > >To: <gameprogrammer@gameprogrammer.com>
> > >Sent: Friday, September 22, 2000 7:49 PM
> > >Subject: Dynamic arrays
> > >
> > >
> > >> Here's a topic that comes up all the time. How do you allocate the
size
> of
> > >> an array after a program has been started. I know you can change the
> size
> > >> of STL vectors but that's not what I want. I imagine it has something
> to
> > >do
> > >> with the char* format, using null-terminated strings maybe, but that
> won't
> > >> work for other data types, and the method behind it is mysterious to
> me.
> > >>
> > >> Would someone mind giving the topic a rundown for me?
> > >>
> > >> thanks,
> > >> SirFern
> > >>
> > >>
> > >> =================================================================
> > >> The GameProgrammer.Com mailing list is for the open discussion
> > >> of any topic related to the art, science, and business of
> > >> programming games. This list is especially tolerant of beginners.
> > >> We were all beginners once
> > >>
> > >> To SUBSCRIBE or UNSUBSCRIBE please visit:
> > >> http://gameprogrammer.com/mailinglist.html
> > >>
> > >>
> > >
> > >=================================================================
> > >The GameProgrammer.Com mailing list is for the open discussion
> > >of any topic related to the art, science, and business of
> > >programming games. This list is especially tolerant of beginners.
> > >We were all beginners once
> > >
> > >To SUBSCRIBE or UNSUBSCRIBE please visit:
> > >http://gameprogrammer.com/mailinglist.html
> >
> >
> >
> > =================================================================
> > The GameProgrammer.Com mailing list is for the open discussion
> > of any topic related to the art, science, and business of
> > programming games. This list is especially tolerant of beginners.
> > We were all beginners once
> >
> > To SUBSCRIBE or UNSUBSCRIBE please visit:
> > http://gameprogrammer.com/mailinglist.html
> >
> >
>
> =================================================================
> The GameProgrammer.Com mailing list is for the open discussion
> of any topic related to the art, science, and business of
> programming games. This list is especially tolerant of beginners.
> We were all beginners once
>
> To SUBSCRIBE or UNSUBSCRIBE please visit:
> http://gameprogrammer.com/mailinglist.html
>

=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html