Here is my question:
Why do i get a error message from eclipse when i type in
1 2
int *pointer;
*pointer = &x;
?
The message is "invalid conversion from int* to int".
I think i understand the message. But when i try it on this way
int *pointer = &x;
i get no error message.
Why? For me it looks like the same.
Or ist this "int *pointer = &x;" equal to "int *pointer; pointer = &x"?
Thanks for helping!
But why can i do this int *pointer = &x;?
Is this not the same like "You get an error because you try to assign the address to the object that your pointer points to (by dereferencing it)."?
Nah, you just need to think about it this way: int* pointer = &x; // Means the same as int *pointer = &x;
Here, you can see that pointer is a pointer to an int variable and we're initializing that pointer to point to the address of x.