Thread: How to create multi-dimension string array

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    8

    How to create multi-dimension string array

    I was thinking to create something like

    Code:
     a = {  {"a1", "a2"}, {"b1", "b2", "b3"} }
    Is it possible to do it in array type?
    Could someone give me some hint how can I acheive this?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You can't assign arrays, but you can initialise them
    Code:
    int main( ) {
      char a[2][3][3] = {  {"a1", "a2"}, {"b1", "b2", "b3"} };
      char *b[2][3] = {  {"a1", "a2"}, {"b1", "b2", "b3"} };
      return 0;
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    8
    thank you again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 03:58 PM
  3. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  5. 2 dimension string array
    By djarian in forum C Programming
    Replies: 4
    Last Post: 05-05-2003, 12:47 AM