"Invalid conversion from int to *int"
So I'm trying to learn how to use pointers, but my compiler has decided I'm not allowed to. Every time I try to assign anything to a pointer I get this error:
Code:
error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive]
pNumber = number;
This is my code.
Code:
#include <iostream>
int main()
{
int number = 6;
int * pNumber;
pNumber = number;
return 0;
}
What am I doing wrong here?
Re: "Invalid conversion from int to *int"
You need to take the address:
Re: "Invalid conversion from int to *int"
Knew I'd be doing something stupid like that, thanks!
Re: "Invalid conversion from int to *int"
A pointer can only store the address of the partilcular variable location.
It cannot store the content.
Hope i could help...:)