Results 1 to 2 of 2

Thread: Arrays of Strings?

  1. #1

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772

    Arrays of Strings?

    Is this possible?

    Code:
    string a[5];
    a[0] = "test 0";
    a[1] = "test 1";
    a[2] = "test 2";
    a[3] = "test 3";
    a[4] = "test 4";
    a[5] = "test 5";
    
    for (int i = 0; i <= 5; i++)
         cout<<a[i];
    The compiler gives me these errors:

    error C2258: illegal pure syntax, must be '= 0'
    error C2501: 'a' : missing storage-class or type specifiers

    Basically what I wanted to do was output some strings in a class. If this isn't possible is there another way of doing this?
    Alcohol & calculus don't mix.
    Never drink & derive.

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    This will work:

    Code:
    string a[6];
    a[0] = "test 0";
    a[1] = "test 1";
    a[2] = "test 2";
    a[3] = "test 3";
    a[4] = "test 4";
    a[5] = "test 5";
    
    for (int i = 0; i < 6; i++)
         cout<<a[i];
    return 0;
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width