[Dev-C++] Question about pointers (beginner)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Christian S. <sm...@xs...> - 2003-05-27 18:17:08
|
From my book:
Given x = 123 and ptr_int = &x after that *ptr_int = 456 has been executed.
What is the value of x?
I thought it was 123 as the pointer *ptr_int is a null pointer and can't
have any value.
This is how I see it:
main ( )
{
int x, *ptr_int;
*ptr_int = 456; /*This pointer is a null pointer at this moment right? */
x =123;
ptr_int = &x; /* As x is just set to 123 and the statement *ptr_int = 456;
was executed before I would think *ptr_int would be 123 */
}
----------
But the books says the value of *ptr_int at the end is 456. How come??
Thanks for your time,
Christian
|