Quote:
Originally Posted by Darkhack
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.