Pointers/addresses

Posts 31–45 of 47 · Page 3 of 4
Quote Originally Posted by Auxilium View Post


Remember it'd give it to Array[1].
Get into the habit it starts from 0. even though you declare [php]int array[3][/php]
it really only goes from [php]array[0] to array[2][/php]
if you dont do this, youll get ugly runtime errors
NO.

I UNDERSTAND THAT.

I am purposely accessing the last array.
Quote Originally Posted by VvITylerIvV View Post
NO.

I UNDERSTAND THAT.

I am purposely accessing the last array.
What for? You'd get bounds errors. My brother got a bsod from a bounds errors once
Quote Originally Posted by Auxilium View Post


What for? You'd get bounds errors. My brother got a bsod from a bounds errors once
I wouldn't get any errors. I am accessing the last array because it's the array I wanted to access. If I were to access array[3] there would be errors, but because there are three arrays, array[2] is perfectly valid.

Quote Originally Posted by Toxic Waltz View Post
just test it
How am I supposed to test that, no matter what happens I get the same result. array[2] = 2222; is either assigning 2222 to array[2] or assigning 2222 to the value pointed by array[2] (which is array[2])

Which means that either way, array[2] ends up getting the value 2222. It's a question that is meaningless but I need to know whether or not it is assigned or the value pointed by array[2] is assigned.
Quote Originally Posted by VvITylerIvV View Post
what happens I get the same result. array[2] = 2222; is either assigning 2222 to array[2] or assigning 2222 to the value pointed by array[2] (which is array[2])

Which means that either way, array[2] ends up getting the value 2222. It's a question that is meaningless but I need to know whether or not it is assigned or the value pointed by array[2] is assigned.
isn't that exactly the same?

you just change the value where array[2] is pointing to to 2222
It's easier to declare it like
[php]int array[3] {number, number, number};[/php]

if you want them to be null, just declare 0, because null is 0 anywayz
Quote Originally Posted by Auxilium View Post
It's easier to declare it like
[php]int array[3] {number, number, number};[/php]
I know that... but I needed to assign just a single array, to ask my question. I understand arrays. I understand how to assign variables to them. I understand everything about them. EXCEPT.

When I use array[2] = 2222;

does it assign 2222 to array[2] or does it assign 2222 to the value pointed by array[2]

PLEASE DO NOT REPLY UNLESS YOU ARE GOING TO ANSWER MY DAMN QUESTION.
Quote Originally Posted by VvITylerIvV View Post
I know that... but I needed to assign just a single array, to ask my question. I understand arrays. I understand how to assign variables to them. I understand everything about them. EXCEPT.

When I use array[2] = 2222;

does it assign 2222 to array[2] or does it assign 2222 to the value pointed by array[2]

PLEASE DO NOT REPLY UNLESS YOU ARE GOING TO ANSWER MY DAMN QUESTION.
They're the same. Like Toxic said.

And array[2] isnt pointed to. It points to array[0]

im going to bed goodnight
Quote Originally Posted by Auxilium View Post


They're the same. Like Toxic said.

And array[2] isnt pointed to. It points to array[0]

im going to bed goodnight
int array[5] = {16, 15, 14, 13, 12 };


assigns the values to an address

as seen here

1232 ------- 1233 ---------- 1234 --------- 1235 --------- 1236 (addresses)
16 ---------- 15 ------------- 14 ------------ 13 ------------- 12 (values)


array[4] would point to the value of 1236, which is array[4]

I'm done here, because nobody understands my question...

I am going to ask both my questions which I need answered here. do NOT reply unless you are going to answer one, if not both. If you have to say anything else do NOT reply.
1. Does array[4] hold a value, or does it point to an address?
2. Does array[4] = 4444 change the value of the address pointed by array[4](1236) or does it directly change the value of array[4]? (they are pretty much the same thing but I need to know which one it does.)


again.
DO NOT REPLY UNLESS YOU ARE GOING TO ANSWER MY DAMN QUESTION.
Quote Originally Posted by VvITylerIvV View Post
int array[5] = {16, 15, 14, 13, 12 };


assigns the values to an address

as seen here

1232 ------- 1233 ---------- 1234 --------- 1235 --------- 1236 (addresses)
16 ---------- 15 ------------- 14 ------------ 13 ------------- 12 (values)


array[4] would point to the value of 1236, which is array[4]

I'm done here, because nobody understands my question...

I am going to ask both my questions which I need answered here. do NOT reply unless you are going to answer one, if not both. If you have to say anything else do NOT reply.
1. Does array[4] hold a value, or does it point to an address?
2. Does array[4] = 4444 change the value of the address pointed by array[4](1236) or does it directly change the value of array[4]? (they are pretty much the same thing but I need to know which one it does.)


again.
DO NOT REPLY UNLESS YOU ARE GOING TO ANSWER MY DAMN QUESTION.
What do you not understand about array[4] points to array[0]
So, it points, doesnt store a value.

and yes, changing the values of pointers changes the pointed object. Like i said in the other thread. Indirect access.

That SHOULD answer your question

An array is just memory stored away to hold values
Btw im going to say something about the pointer initialization. Either initialize it with NULL (already said, not sure), or just use malloc to allocate the memory for it.

Btw why are you learning Array now? i remember i learned about arrays before strings and etc... (C)
Quote Originally Posted by 'Bruno View Post
Btw im going to say something about the pointer initialization. Either initialize it with NULL (already said, not sure), or just use malloc to allocate the memory for it.

Btw why are you learning Array now? i remember i learned about arrays before strings and etc... (C)
I stated that on my other account
Quote Originally Posted by rtemis View Post
I stated that on my other account
Patrick.....?
Quote Originally Posted by Void View Post
Patrick.....?
I seriously don't know why i was banned /
array[4] = array[0] + 4*size of 1 item

so if your array is located at 0x1337, array[4] would be located at 0x133B.
Quote Originally Posted by Hell_Demon View Post
array[4] = array[0] + 4*size of 1 item

so if your array is located at 0x1337, array[4] would be located at 0x133B.
ok thank you
Posts 31–45 of 47 · Page 3 of 4

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us