Thread: multi-dimensional arrays

  1. #1
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369

    multi-dimensional arrays

    Is there anyway you could make one part of a multi-dimensional array char* and another int, like this?

    Code:
    array[2][2] =
    {
         char*, int,
         char*, int,
    }
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  2. #2
    Registered User
    Join Date
    Feb 2003
    Posts
    60

    Talking

    The main thing I wanted to do was have user defined characters as game pieces. ('X', 'O' etc) I realise now that because I'm just using a simple multidimension array [9][9] it isn't a string!! (That's where I was confused...)

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    Use a struct!

    Code:
    struct
    {
        char* str;
        int val;
    } array[2];
    
    ex:
    cout << array[1].str << endl;

  4. #4
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    Thanks, I'll try to implement that!
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multi dimensional array
    By $l4xklynx in forum C Programming
    Replies: 7
    Last Post: 01-03-2009, 03:56 AM
  2. fscanf for multi dimensional arrays
    By rambos in forum C Programming
    Replies: 7
    Last Post: 05-06-2008, 03:26 AM
  3. Pointers and multi dimensional arrays
    By andrea72 in forum C++ Programming
    Replies: 5
    Last Post: 01-23-2007, 04:49 PM
  4. Replies: 6
    Last Post: 04-26-2004, 10:02 PM
  5. Pointers to multi dimensional arrays.
    By bartybasher in forum C++ Programming
    Replies: 2
    Last Post: 08-25-2003, 02:41 PM