-
February 13th, 2014, 10:07 PM
#1
"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?
-
February 13th, 2014, 10:12 PM
#2
Re: "Invalid conversion from int to *int"
You need to take the address:
-
February 13th, 2014, 10:14 PM
#3
Re: "Invalid conversion from int to *int"
Knew I'd be doing something stupid like that, thanks!
-
February 17th, 2014, 03:01 AM
#4
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...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|