2d arrays

This is a discussion on 2d arrays within the C++ Programming forums, part of the General Programming Boards category; i want to make a matrix of around 1000 by 1000 but i cannot do it by the conventional 2d ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    9

    2d arrays

    i want to make a matrix of around 1000 by 1000 but i cannot do it by the conventional 2d array method. i get an error of "stack overflow". kindly tell me how to make the matrix.
    thanx

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    If you don't have a 4MB stack, then you can use new. If the 1000 is fixed, then you can do something like:
    Code:
    typedef int row[1000]; // row now means "an array of 1000 ints"
    
    row *array;
    array = new int[1000][1000]; //or new row[1000];
    Last edited by tabstop; 05-05-2010 at 11:30 AM. Reason: FIXED bad code

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing 2D arrays between functions
    By taurus in forum C Programming
    Replies: 10
    Last Post: 09-28-2009, 05:05 AM
  2. Help with 2d arrays
    By thamiz in forum C Programming
    Replies: 25
    Last Post: 05-25-2008, 05:06 AM
  3. 2D Array's, assigning chars.
    By gman89 in forum C Programming
    Replies: 9
    Last Post: 04-26-2008, 11:03 PM
  4. Initialising 2D and 3D arrays
    By fry in forum C++ Programming
    Replies: 5
    Last Post: 08-01-2002, 04:34 AM
  5. Reading 2d arrays from file?
    By Ringhawk in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2002, 08:05 PM

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