|
-
Feb 24th, 2002, 07:48 PM
#1
Thread Starter
Stuck in the 80s
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.
-
Feb 24th, 2002, 08:38 PM
#2
Fanatic Member
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.
-
Feb 24th, 2002, 08:49 PM
#3
Thread Starter
Stuck in the 80s
oh...I thought it started with 0?
-
Feb 25th, 2002, 12:11 AM
#4
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.
-
Feb 25th, 2002, 06:44 PM
#5
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|