Quote:
Originally Posted by .Owyn.
yes my array is only strings and i don't need [j], in what condition will i needit ? still don't get the [j] thing
|
CheatReports is a 2-dimension array which means it is an array of arrays ... or in this case it can be referred to an array of strings.
A 1-dimension array is like so:
new TheArray[] = { 5 , 33 , 55 , 66 , 102 };
If we wanted to access 55 in this array, we would refer to it with TheArray[ 2 ] because the elements start at 0 for index and we want the 3rd element which is the number 55. 0=5, 1=33, 2=55 3=66 4=102
A 2-dimension array (array of strings).
new TheArray[][] = { "hello" , "my" , "friend" };
What this does is creates an array sized @ [ 3 ][ 7 ], the second dimension is 7 because it is automatically allocated to be large enough to store the largest string specified plus a null character, in this case "friend" which is 6 chars long + 1 so 7.
The array looks like this as far as memory is concerned:
0 = "hello**"
1 = "my*****"
2 = "friend*"
* = NULL or 0
To access the word "my" you use TheArray[ 1 ] because the word "my" is the 2nd element in the array and again, the array begins at a 0 index. 0="hello", 1="my", 2="friend".
About [j]:
If you want to access only a portion of the string you can specify the 2nd dimension. Example, suppose you wanted to access only "end" in the word "friend" you would do TheArray[ 2 ][ 3 ]. This is because the word "friend" is located at index 2 of the string array and "end" is found at index 3 of the word "friend"; 0=f 1=r 2=i 3=e.
See the Strings section in this
tutorial.
__________________