Results 1 to 2 of 2

Thread: empty array

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    425

    Question empty array

    how do i declare a 2D array which is empty?

    like int array[][];

    then then i can decide on the number of rows and cols based on what the user given

    and how do i write function for a 2D array

    void array(int array[][] ) ???
    or
    void array(int array[row][col] , int row , int col)

    ??

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    There is two ways to do this (FYI its called dynamically declared array).

    The easiest way is to used linked list, which if you search this form you are bound to find alots of examples for.

    The other way is to use new and delete to make a new array and to delete it. The hard part about doing it this way is you have to move the data out of your array delete it, resize it making using new, copy the data back, then delete your temp array. Again if you search this for you should find examples.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width