Thread: define array size at later stage of program?

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    58

    define array size at later stage of program?

    Hi

    I am looking for a way to declare a global array with no indication of size. Then later on in the application I need to set the array to a specific size (depending on what the code is going to be doing).

    The array will need to visible/accessible for all methods in the class – has anyone got any ideas?

    Thank you very much

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    396
    Option#1: a pointer as global variable and malloc() to allocate the array later...

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by DavidDobson View Post
    Hi

    I am looking for a way to declare a global array with no indication of size. Then later on in the application I need to set the array to a specific size (depending on what the code is going to be doing).

    The array will need to visible/accessible for all methods in the class – has anyone got any ideas?

    Thank you very much
    There's no such thing as a class in C.
    Are you posting in the wrong forum? If so, I'd suggest using a std::vector to solve your problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Algorithmic Mastermind Program
    By pr0n in forum C Programming
    Replies: 1
    Last Post: 05-12-2008, 11:02 PM
  2. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  3. whats wrong here
    By sreetvert83 in forum C++ Programming
    Replies: 15
    Last Post: 09-21-2005, 10:05 AM
  4. How to complete program. Any probs now?
    By stehigs321 in forum C Programming
    Replies: 7
    Last Post: 11-19-2003, 04:03 PM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM