Invalid operands?

1
2
3
4
5
6
if(*(arrPtr + j) > *(arrPtr + (j+1)))
            {
                temp = *(arrPtr + j);
                *(arrPtr + j) = *(arrPtr + (j+1))
                *(arrPtr + (j+1)) = temp;
            }


Not sure what it means, but the last line I am getting an error for.

Telling me


Invalid operands for types 'int' and '*int' to binary 'operator*'

Never seen this message before

EDIT:
Sorry that's 'int*', not '*int'
Last edited on
Woow, nevermind. Forgot a semi colon. Though I was past doing that haha
It means (not really) that you forgot a semicolon.
Also, for future reference:
if(arrPtr[j] > arrPtr[j+1])std::swap(arrPtr[j],arrPtr[j+1]);
Yea I know about swap, I was just wanting to be fancy here. And didn't know if it applied when using pointers.
Topic archived. No new replies allowed.