Penny Arcade
The Trenches
PAX
Child's Play
Pinny Arcade
Sign In
Join Club PA
Penny Arcade
Comics
News
PATV
Podcasts
Archive
Forum
Shop
Best Of...
Sign In
·
Register
Penny Arcade Forums
›
Help / Advice Forum
Quick Links
Categories
Recent Threads
Best Of...
The new forums will be named Coin Return (based on the most recent
vote
)! You can check on the status and timeline of the transition to the new forums
here
.
The Guiding Principles and New Rules
document
is now in effect.
C++ lists & arrays (solved)
curby
Registered User
regular
January 2008
edited January 2008
in
Help / Advice Forum
So, long story short, I would like to copy a linked list to an array, but I'm not sure how to make arrays of variable size at run time. For example,
void ToArray( const int size ) { // doesn't work int newArray[size]; ... }
Any ideas?
curby
on
January 2008
0
Posts
DrFrylock
Registered User
regular
January 2008
edited January 2008
int* p_int = new int[size];
Remember to free it when you're done.
DrFrylock
on
January 2008
0
zilo
Registered User
regular
January 2008
edited January 2008
Remember to use 'delete [] thing', not 'delete thing'. Using the wrong delete operator is a fun source of memory leaks.
zilo
on
January 2008
0
curby
Registered User
regular
January 2008
edited January 2008
Cool, thanks. That helps a lot.
curby
on
January 2008
0
Sign In
or
Register
to comment.
Penny Arcade Forums
›
Help / Advice Forum
Powered by Vanilla
Posts
Remember to free it when you're done.