How to create multi-dimension string array

This is a discussion on How to create multi-dimension string array within the C Programming forums, part of the General Programming Boards category; I was thinking to create something like Code: a = { {"a1", "a2"}, {"b1", "b2", "b3"} } Is it possible ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,767
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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, 03:45 PM
  2. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 04:58 PM
  3. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 01:56 PM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 08:48 PM
  5. 2 dimension string array
    By djarian in forum C Programming
    Replies: 4
    Last Post: 05-05-2003, 01:47 AM

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