Results 1 to 5 of 5

Thread: Arrays

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Arrays

    I want to define a string array and it's values at the same time, like:

    string mystr[2] = "zero","one","two"

    or like in vb:

    mystr(2) = Array("zero", "one", "two")

    Is this possible?
    Last edited by The Hobo; Feb 24th, 2002 at 08:49 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Almost right
    Code:
    string mystr[3] = {"zero", "one", "two"};
    Remember, there are three things in the array, so you need to put a 3 in there.
    Alcohol & calculus don't mix.
    Never drink & derive.

  3. #3

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    oh...I thought it started with 0?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Zaei
    Guest
    It does, but you define by the number of elements in the array.

    You also dont need the value there, the compile will figure out how big the array is by the number of elements inside the curly braces.

    Z.

  5. #5
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Say you have this:
    Code:
    string mystr[] = {"bob", "bill", "buck"};
    It has three things in it. The 0th thing is "bob", the 1st thing is "bill", and the 2nd is "buck".
    Alcohol & calculus don't mix.
    Never drink & derive.

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