#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    3
    Rep Power
    0

    Question Resizing a global array in C++


    Question: In C++, what is the best way (if any) to have a function resize a global integer array that has already been declared?

    Here is the whole story if you care to hear it. I need to declare an integer array globally at the beginning of the program, but, later in the program, the user needs to enter a number that will re-define the size of the array.
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    Try declaring a pointer variable then and resize it using new and delete. Another alternative would be to use the STL vector class instead. Check this forum or google for lots of examples
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    3
    Rep Power
    0

    Thank You Very Much


    Oh, thank you thank you thank you! I completeley forgot about vectors! (Its been a while since computer science I) That should work very nicely. Thank you!

IMN logo majestic logo threadwatch logo seochat tools logo