Computer Science Canada really simple array problem |
Author: | shoobyman [ Sat Feb 11, 2006 7:33 pm ] | ||
Post subject: | really simple array problem | ||
i am teh noob of teh forums, so can u guys help me? i am trying to learn arrays, but no matter how much i try to call up the variable, it will not display it. i can make it appear, but only if i use the "init" command. this is my code, and each time i run it, it says that variable has no value.
|
Author: | Cervantes [ Sat Feb 11, 2006 7:47 pm ] | ||||
Post subject: | |||||
If it says the variable has no value, it probably has a pretty good reason for saying so. number (2) does not mean the integer, 2. It refers to the second element of an array of variables. In this case, you have not assigned the second element (or any elements, for that matter) a value. To do so, you'd do this:
Or perhaps we could do this:
|
Author: | shoobyman [ Sat Feb 11, 2006 7:53 pm ] |
Post subject: | |
oooooooooooo, it doesn't mean integer 2, that makes more sense i just gotta declare what number (2) is, thanx! lol me is noob ![]() |
Author: | MysticVegeta [ Sat Feb 11, 2006 11:38 pm ] | ||
Post subject: | |||
or..
Now, you wont get an error because the corresponding element at the index of 2 is 2. |
Author: | Martin [ Sun Feb 12, 2006 12:04 pm ] | ||||
Post subject: | Re: really simple array problem | ||||
shoobyman wrote: i am teh noob of teh forums, so can u guys help me?
i am trying to learn arrays, but no matter how much i try to call up the variable, it will not display it. i can make it appear, but only if i use the "init" command. this is my code, and each time i run it, it says that variable has no value.
What your code does is creates a set of 10 integer variables. Your code is the equivalent of:
|
Author: | shoobyman [ Sun Feb 12, 2006 6:01 pm ] |
Post subject: | |
thank you all, very helpful, i now completely understand arrays, (it wasn't nearly as hard as i thought) ![]() ![]() |