Thread: assigning values to multidimensional array

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    50

    assigning values to multidimensional array

    I know how to assign values to a one-dimensional array.

    How do you assign values to a 2 dimensional one ?

    for example

    cards[9]={1,2,3,4,5,6,7,8,9};


    but for 2 dimensional ?

    cards[9][2]= ????

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    well there are a couple ways:
    Code:
    cards[3][2] = { {0,1}, {2,3}, {4,5}};
    cards[3][2] = { 0, 1, 2, 3, 4, 5 };
    Both initalize the same locations with the same values

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    50
    Thank you so much for this. You were very quick and I appreciate that.

    Now back to my program

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 11-19-2008, 02:36 PM
  2. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  3. assigning values in file to an array
    By divinyl in forum C++ Programming
    Replies: 9
    Last Post: 07-29-2003, 08:33 AM
  4. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM
  5. Multidimensional Array
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 11-17-2001, 06:18 PM