Re: [Dev-C++] Question about pointers (beginner)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <or...@vp...> - 2003-05-27 21:00:20
|
Avik Ghose wrote:
> I think still x will be 456. Lets look at it this way.
> x=123.
> p=&x
> now *p implies the content of the address pointed to by p which is
> nothing but the memory symbolised by the name 'x'.
> hence when *p=456 is set, after that.
> x will also be equal to 456
WAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!!!!
ME FOOOOOOOOOOOOL!!!
It is a serious TYPO!!!!
I thought 456, and I wrote 123!
Stupid, fool, idiot...
I'll correct it:
If I implemented this, this is how I would do it:
#include
main()
{
int x, *ptr_int;
x = 123; /* Given x = 123 */
ptr_int = &x; /* and ptr_int =&x */
*ptr_int = 456; /* after that *ptr_int = 456 has been executed */
printf("%d",x); /* What is the value of x? */
/* ***CORRECTED***: THE ANSWER IS: 456 */
}
Sorry, and thanks.
It was a typo. My brain sometimes is out %)
--
Greetings,
Balázs
|