View Single Post
Old Jun 27th, 2007, 11:01 PM   #5
Fall Back Son
Professional Programmer
 
Join Date: Oct 2006
Posts: 263
Rep Power: 2 Fall Back Son is on a distinguished road
Quote:
Originally Posted by Darkhack View Post
I do not think that is quite right. My reasoning is because the following program will display the number three just fine. Compiler doesn't show any warnings and it executes perfectly and displays the number, even though I am initilizing it without pointing to an existing variable.
What is your reasoning behind typecasting an integer value to a pointer anyway? This seems like a pointless operation. You're treating the integer 3 as a "pointer to an integer". In any case, assigning integer expressions to pointer variables is an illegal operation. Had you tried to say

int *x = 3 ;

you would (or should anyway), get a compiler warning. You can assign 0 to a pointer though, to indicate that it points nowhere. Btw, I think Dameon was right.
Fall Back Son is offline   Reply With Quote