adding 1 to a value via a pointer too it

in playing with sorting algorithms i tried a quick sort copied from a website and passed in as an extra argument a pointer to count just to see how many operations it saved (439,152 iterations provided of course my count works) my first try was to increment count with *count++ this produced a warning saying computed value not used so i tried *count += 1 no warning and it worked.

question is can you not use the ++ operator on pointers in that sense or more likely did i do something wrong.

++ is higher in precedence than * Indirection (dereference) therefore the pointer in incremented instead of the value it points to.

Tim S.

"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

stahta01 is correct, but I thought I'd point out one additional observation about this situation.

When operator precedence governs the meaning of the statement, it may be that you need to consider parenthesis to clarify.

Code:

void f( int * count )
{
++ (*count);
(*count)++;
}

Without the parenthesis it is up to operator precedence, but with them you've clearly stated you intend (*count) to be evaluated first as the dereference of the pointer, meaning the int and not the pointer to an int. The ++ is then clearly applied to that int.