Thread: 2d dynamic array

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    30

    2d dynamic array

    hi!
    does anyone know a good way to implement dynamic 2d array in c++ using STL?

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    std::vector< std::vector<type> > myvec;
    Or if you need a static array, you can use std::tr1::array.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    30
    Quote Originally Posted by Elysia View Post
    std::vector< std::vector<type> > myvec;
    Or if you need a static array, you can use std::tr1::array.
    Thanx for pointing me in the right direction-

    vector< vector<int> > myvec(n,vector<int>(n));

    works perfectly!
    cheers!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. put matrix from file into 2d dynamic array
    By meriororen in forum C Programming
    Replies: 3
    Last Post: 06-08-2009, 07:51 AM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. Allocating a 2D Array Differently
    By pianorain in forum C++ Programming
    Replies: 13
    Last Post: 12-15-2005, 02:01 AM
  4. 2D dynamic array problem
    By scsullivan in forum C Programming
    Replies: 3
    Last Post: 12-30-2002, 10:02 PM
  5. how to pass 2D array into function..?
    By IngramGc in forum C++ Programming
    Replies: 2
    Last Post: 10-21-2001, 08:41 AM