|
-
March 8th, 2013, 11:19 AM
#4
Re: Why "char" is inside "int" loop?
 Originally Posted by RyuMaster
Thank you. Probably looping using pointers has some speed gain, but really, that is my 3rd question regarding C++ and solution is related to pointers again. Next time I stuck, I'll just go back and read about the pointers. So can I assume then, that:
C++: *array+1 is same as
C#: array[0+1]
for chars, and for other value types I have to get their sizes first.
Right. From what I posted above "When calculating the result of a pointer arithmetic expression, the compiler always multiplies the integer operand by the size of the object being pointed to. This is called scaling."
The compiler knows how much to increment the pointer. You don't need to worry about it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|