Thread: 3 Dimentional string Arrays

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    16

    Talking 3 Dimentional string Arrays

    how do i make a 3 Dimentional string Array in miracle c?

    i want to store 3 lists of names:
    eg

    bob,fred,jeff
    sid,paul,carl
    |
    |
    V
    ETC....

    thankz for the help peoplez...
    Shizzle Ma 'C' Whizzle's

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Haven't used Miracle C, but if it like 'standard' C, then this should work:
    Code:
    #define NrOfTriples 2
    #define MaxLengthOfOneString 32
    
    char StringArray[NrOfTriples][3][MaxLengthOfOneString];
    strcpy(StringArray[0][0], "Bob");
    strcpy(StringArray[0][1], "Fred");
    strcpy(StringArray[0][2], "Jeff");
    
    strcpy(StringArray[1][0], "Sid");
    strcpy(StringArray[1][1], "Paul");
    strcpy(StringArray[1][2], "Carl");
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    16
    Thankz works sound

    <code>
    for(i=0;i<2;i++)
    {
    printf("\n");
    for(j=0;j<3;j++)
    {
    printf("%s\t\t",StringArray[i][j]);
    }
    }
    <\code>

    i hav another prob wiv this line of code tho :S
    i get this error message

    arraytest.c: line 24: wrong # args in function call
    '{ printf("%s\t\t",StringArray[i][j])'
    aborting compile
    Shizzle Ma 'C' Whizzle's

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    16

    Lightbulb

    o yeah, Silly me, i think ive lost my brain today lol
    Shizzle Ma 'C' Whizzle's

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. String Class
    By BKurosawa in forum C++ Programming
    Replies: 117
    Last Post: 08-09-2007, 01:02 AM
  3. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  4. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 11:06 PM
  5. string handling
    By lessrain in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 07:36 PM