Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Ragadast

Arrays

This topic is 5861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've seen some examples making something like this with arrays:
int array[50][50] = {1, 0, 1, 1, 1, 0, 0,
                     0, 1, 1, 0, 0, 0, 1,
                     0, 0, etc...}
 
I've never seen a tutorial explaining arrays used in that way, but I think it might be useful for something I'm doing. So, could someone explain me how it works please? [edited by - Ragadast on June 2, 2002 2:54:00 PM]

Share this post


Link to post
Share on other sites
Advertisement
Nuh-uh. Not with a 2D array. To do that you''d have to say
int array[50][50] =
{ { 0, 0, 0, 0, 0, ...}, {0, 0, 0, 0, 0, 0, ...}, ...};

In other words, each row is an array, a subset of the matrix. You have to set each element in each row as shown above if you want to do that.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

Share this post


Link to post
Share on other sites
Ok. But what''s the mean of

{0, 1, 1, 1, 0, 1}?

Is it a number? Each line of numbers correspond to one of the elements of the array, right?

Share this post


Link to post
Share on other sites
If you have this array:

int array [3][3] = { {2, 4, 6}, {8, 10, 12}, {14, 16, 18} };

then if you want to assign the number 12 in this array to another variable, you would write this:

int some_value;

some_value = array[2][3];

...or if you want to assign the number 16 to another variable you write this:

int another value;

another_value = array [3][2];

did this help?

Share this post


Link to post
Share on other sites
If you have this array:

int array [3][3] = { {2, 4, 6}, {8, 10, 12}, {14, 16, 18} };

then if you want to assign the number 12 in this array to another variable, you would write this:

int some_value;

some_value = array[2][3];

...or if you want to assign the number 16 to another variable you write this:

int another value;

another_value = array [3][2];

did this help?

Share this post


Link to post
Share on other sites
wait a sec, isn''t the first element of an array supposed to be labled 0?

so in this case, if you want to assign the number 12 in the array to another variable, wouldn''t you write this:

int some_value;

some_value = array[1][2];

correct me if i''m wrong...still a bit sketchy on arrays.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!