Skip to main content
gamedev.net
🔒 Locked

String Usage and Architecture

Started by Myopic Rhino Mar 11, 2004 at 3:25 PM 8 replies 950+ views
Wc-duck
Wc-duck
Read this right now and needed to point out an error:

The author says "myarray[2] is really just shorthand for *(myarray+2)". That is not true myarray[2] is the same as *(myarray+sizeof(myarray_element_type)) and that is acctually a huge difference.
grekster
grekster
Quote:
Original post by Wc-duck
Read this right now and needed to point out an error:

The author says "myarray[2] is really just shorthand for *(myarray+2)". That is not true myarray[2] is the same as *(myarray+sizeof(myarray_element_type)) and that is acctually a huge difference.


Actually im fairly sure that myarray[2] and *(myarray+2) are exactly the same.
Quote: Original post by BosskIn Soviet Russia, you STFU WITH THOSE LAME JOKES!
Evil Steve
Evil Steve
Quote:
Original post by Wc-duck
The author says "myarray[2] is really just shorthand for *(myarray+2)". That is not true myarray[2] is the same as *(myarray+sizeof(myarray_element_type)) and that is acctually a huge difference.
No it's not. The element size is implicit in both cases. The only time the element size matters is if you're dealing with raw bytes, such as for memcpy().

myarray[2] is the same as *(myarray+2). Try it with an array of ints and see.
Wc-duck
Wc-duck
ahh... missed the mulitplication with the index. My bad.
Wc-duck
Wc-duck
Are you sure that the size is implied? I have done the exact same thing some time ago and i sertainly did not work. But I'll try it again when I get home (at "work" now).
Wc-duck
Wc-duck
ok... I was wrong. Tested and verified now.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.