There is ALWAYS an implied multiplication when incrementing pointers, since it always involves the size of the type it points to. Where the increment is a constant, the multiplication happens in the compiler, not at runtime.
I see. That is an interesting distinction and it also answers my question. Good to know. Incrementing a pointer results in no multiplication *at runtime*, when using a constant, but multiplication is always needed. I guess it is safe to assume the compiler treats ptr++ as a constant too, correct? So it ends up avoiding the runtime multiplication penalty. So technically, *at runtime*, ptr++ requires no multiplication. That is what I had in mind when writing my statement above -though it was not completely accurate or if we are being pedantic, simply not accurate at all- and I appreciate the clarification.
Now you're not making an sense at all.
Well, I am interested in eliminating the multiplication penalty in a particular loop in my code; Why? simply for performance reasons. Technically if I increase the pointer as I show in that little loop in my comment above, I'm forfeiting the mandatory sizeof operation every time I increase the pointer (assuming my assertion above that ptr++ is indeed treated as a constant); but the resulting code will probably be slower than doing a regular ptr += x.
I hope I'm making sense now. If not, I'm blaming my lack of sleep. Again.
As for the pointer being reset. I have to clarify, in this case I was referring to a char **ptr.
Dereferencing ptr like this (*prt) += x, leads to *ptr being reset to it's original address when x = 0. I didn't know this. The same way I didn't know that increasing the copy of a dereferenced pointer would also increase the content of the original poitner. i.e
Code:
char **ptr = //assume something valid;
char **ptr2 = ptr;
(*ptr2)++;
*ptr == *ptr2; //True
If this not normal, I am more than happy to provide the code, and platform.