Understanding Pointers - Easy Questions.
I'm having so much trouble grasping pointers. I'm experimenting with pointers and I expect to ask several questions on this thread. My first confusion is notation.
I've gotten over declarations at this point. If I do
Code:
int main ()
{
int *ptr;
}
ptr is a pointer. But I'm confused about using it in code. When I use ptr, there are times when I don't include the star and times when I do. How can I know when to use it?
for instance, given that *numPtr is declared:
*numPtr = malloc(sizeof(int));
does not work, but
numPtr = malloc(sizeof(int));
does work. So here I need to use the star char.
But when I use the equal operator, I cannot use the star symbol. Why not?
PtrPtr = numPtr (correct)
printf("%i\n", *PtrPtr); (requires a star, won't work without it. Why not?)
Please help me actually understand this, not memorize it.