I just started to study C, and when doing one example about passing pointer to pointer as a function\'s parameter, I found a problem.
This is my sample code :
Let's apply parentheses to show the order of operations
a + b / c
a + (b/c)
Let's do it again with
*ptr += 1
(*ptr) += 1
And again with
*ptr++
*(ptr++)
*ptr += 1, we increment the value of the variable our pointer points to.*ptr++, we increment the pointer after our entire statement (line of code) is done, and return a reference to the variable our pointer points to.The latter allows you to do things like:
for(int i = 0; i < length; i++)
{
// Copy value from *src and store it in *dest
*dest++ = *src++;
// Keep in mind that the above is equivalent to
*(dest++) = *(src++);
}
This is a common method used to copy a src array into another dest array.