View Single Post
Old Jun 27th, 2007, 11:20 PM   #6
Fall Back Son
Hobbyist Programmer
 
Join Date: Oct 2006
Posts: 204
Rep Power: 2 Fall Back Son is on a distinguished road
"does not work if I initilize the pointer to a value."

http://www.csee.umbc.edu/201/spring0...ures/pointers/

Specifically, I have no idea what "int *x = (int *)3 ; does . It treats 3 as type int * which doesn't make any sense to me, other than the obvious. What it does in memory, I don't know. Dameon may have been correct in his first post, but I'm not sure either.

also:

int z = (int)*x+*y;

would not work the way you want if y was type float. I'm pretty sure only *x is typecasted to an int. You should put the whole expression in parentheses,

int z = (int)(*x+*y);
Fall Back Son is offline   Reply With Quote