Is p* another way of using pointers?
Is *p, a pointer variable, different from p*?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The syntax
Means to dereference the pointer to get the object it points at.
The syntax
Is not meaningful in C, unless it’s the start of a multiplication. For example:
Means “dereference ptr, then multiply the value it points at by 137.”. Outside of this context, though, putting a star after a pointer variable is illegal.
Now, what is legal is putting a star after a type, as in
Which describes a type that’s a pointer to the type to the left of the star. Interestingly, this means that you can’t put a star before a type (that’s not legal) nor a star after a pointer (since the dereference operator goes to the left). The reason is partly due to the idea that in C, types should mimic how they work. That is, if you have
Then the syntax is a visual cue that to get to the integer pointed at by p, you should put a star in front of it.