array problems

This is a discussion on array problems within the C++ Programming forums, part of the General Programming Boards category; hi im having some problems with making an array could any of you find the problem in this? Code: char ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    224

    Question array problems

    hi im having some problems with making an array could any of you find the problem in this?


    Code:
            char armap[][]={
            {"+oooooooooooooooooooooooo+"},
            {"|                        |"},
            {"|                        |"},
            {"|                        |"},
            {"|                        |"},
            {"|                        |"},
            {"|                        |"},
            {"|                        |"},
            {"|                        |"},
            {"|                        |"},
            {"|                   0    |"},
            {"+oooooooooooooooooooooooo+"}};
    there is just as many spaces as "o" in the array
    Last edited by c++.prog.newbie; 04-25-2004 at 09:36 PM.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    What error(s) are you getting?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Nevermind. Just take off the braces on the inside strings.

    Code:
    char armap[][]={
            "+oooooooooooooooooooooooo+",
            "|                        |",
            ...
            };
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    oh.... ok thanks that was kindof a stupid mistake... i wonder why i put them there?

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    i still get the errors

    declaration of 'armap' as multidimensional array must have bounds for all dimensions except the first.

    assignment (not initialization) in declaration

    'armap' undeclared (first use this function) <--- this one is somewere else in the code when i try to access armap[][]

    (each endeclared identifier is reported only once for each function it appears in.)

    rather than making a new post ill just edit and take away the errors as i fix them
    Last edited by c++.prog.newbie; 04-25-2004 at 10:04 PM.

  6. #6
    Registered User
    Join Date
    Apr 2004
    Posts
    29

    excerpting from your discussion

    I'd like to ask a question about what I did to creatively alter the code you posted on the c-board. Here is a peek

    #include <stdio.h>
    void main(void)
    {
    char MatrixA[6][12]=
    {"{ 10, 32, 54, 11 , 99, 11 }",
    "{ 10, 32, 54, 11 , 99, 11 }",
    "{ 10, 32, 54, 11 , 99, 11 }",
    "{ 10, 32, 54, 11 , 99, 11 }",
    "{ 10, 32, 54, 11 , 99, 11 }",
    "{ 10, 32, 54, 11 , 99, 11 }",
    "{ 10, 32, 54, 11 , 99, 11 }",
    "{ 10, 32, 54, 11 , 99, 11 }",
    "{ 10, 32, 54, 11 , 99, 11 }",
    "{ 10, 32, 54, 11 , 99, 11 }",
    "{ 10, 32, 54, 11 , 99, 11 }",
    "{ 10, 32, 54, 11 , 99, 11 }"};
    printf("This program will multiply the Matrix A per matrix position such that \n
    position2_x=position1_x+i and i=1; and position2_y=position1_y+j and i=j.\m");

    }

    I'll post my question on the .c board

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    i dont think i understood what all that was about

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,592
    > declaration of 'armap' as multidimensional array must have bounds for all dimensions except the first.
    It means you can't have array[][]
    You need to specify the size of the minor dimension - like array[][100]

    For strings, there is an easy way out, and that's to make an array of pointers to the strings
    Code:
    char *armap[]={
            "+oooooooooooooooooooooooo+",
            "|                        |",
            "|                        |",
            "|                        |",
            "|                        |",
            "|                        |",
            "|                        |",
            "|                        |",
            "|                        |",
            "|                        |",
            "|                   0    |",
            "+oooooooooooooooooooooooo+"
    };
    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.

  9. #9
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    in this case, since c++.prog.newbie knows the sizes of all the dimensions and they won't change, wouldn't it be better just to put both dimensions in?
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  10. #10
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    it still does the same thing if i put both dimensions but ill try again

  11. #11
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787

    redundant threads...

    somebody should really merge this with that
    Last edited by major_small; 04-26-2004 at 11:24 AM. Reason: different word
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 20q game problems
    By Nexus-ZERO in forum C Programming
    Replies: 24
    Last Post: 12-17-2008, 04:48 PM
  2. Have problems with copying my array!
    By AvaGodess in forum C Programming
    Replies: 11
    Last Post: 09-25-2008, 12:56 AM
  3. Problems passing an array to a function
    By ndenklau in forum C Programming
    Replies: 5
    Last Post: 09-20-2006, 08:14 AM
  4. Helllppp!!! I/O and array problems
    By dorky in forum C++ Programming
    Replies: 3
    Last Post: 07-02-2005, 09:24 AM
  5. Creating 2D arrays on heap
    By sundeeptuteja in forum C++ Programming
    Replies: 6
    Last Post: 08-16-2002, 11:44 AM

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