Thread: dinamic array question

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    dinamic array question

    How can i create a 2D array.
    For which i could change its size
    change its form

    like creating an array of one size and later in the program i could change this variable
    ??
    Last edited by transgalactic2; 12-17-2008 at 04:20 PM.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, that can be done. You need to use either an array of pointers (if the leftmost dimension is known or a reasonable maximum can be estimated) or a pointer to pointer (fully flexible solution).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Dec 2008
    Posts
    104
    As matsp said, your best off using a pointer in which you allocate an amount of memory, and then are able to allocate another amount of memory, and then be able to free any unused memory.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic Mutli dimensional Array question.
    By fatdunky in forum C Programming
    Replies: 6
    Last Post: 02-22-2006, 07:07 PM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. Array of Structs question
    By WaterNut in forum C++ Programming
    Replies: 10
    Last Post: 07-02-2004, 02:58 PM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  5. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 01:01 AM