My CS course is taking a bit of a turn from Java to C. I'm busy going over pointers at the moment and I have come across that the ++ operator for incrementing doens't work when dereferencing. This is more just a curiosity question than anything else. Just not used to the pointers concept just yet. Am I just doing something wrong or is it something to do with pointers?
For example:
*pointer++; Will not increment the value.
*pointer+=1; Will increment the value.
Thanks in advance!
When you want to increment the value you have to make sure you use parenthesis.
(*pointer)++;
*pointer++;
is equivalent to
*(pointer++); // pointer is incremented
and not to
(*pointer)++; // pointee is incremented
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With