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)

curbycurby Registered User regular
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?

linktous.gif
curby on

Posts

  • DrFrylockDrFrylock Registered User regular
    edited January 2008
    int* p_int = new int[size];

    Remember to free it when you're done.

    DrFrylock on
  • zilozilo Registered User regular
    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
  • curbycurby Registered User regular
    edited January 2008
    Cool, thanks. That helps a lot.

    curby on
    linktous.gif
Sign In or Register to comment.