define array size at later stage of program?

This is a discussion on define array size at later stage of program? within the C Programming forums, part of the General Programming Boards category; Hi I am looking for a way to declare a global array with no indication of size. Then later on ...

  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
    395
    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-13-2008, 12:02 AM
  2. Replies: 3
    Last Post: 05-13-2007, 09:55 AM
  3. whats wrong here
    By sreetvert83 in forum C++ Programming
    Replies: 15
    Last Post: 09-21-2005, 11: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, 10:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21