Advertisement

Values from Pointers

Started by April 28, 2000 03:55 PM
1 comment, last by Zipster 24 years, 7 months ago
Lets say i have:

int x;
int y;
int *p_x; // Pointer to x

x = 10;
p_x = &x
...........
 
Now lets say i want to assign the value that p_x points to, to y. So i want y to equal whatever x is, through the p_x pointer. I tried:

&y = p_x;
 
but the compiler doesn''t like this . I''ve been thinking about this and whenver i try something new it doesn''t work. Any suggestions?
y = *p_x;

That should do what you want.
Advertisement
So that "*" (in this situation) means "the value pointed to by...". OK, I always used it to make pointers, and i know that & means "address of...".

Thx

This topic is closed to new replies.

Advertisement