Re: Swapping
From: Alex Monjushko (monjushko_at_hotmail.com)
Date: 07/16/04
- Next message: Thomas Matthews: "Re: help to read files"
- Previous message: Pavel Sorokin: "memory access error in some simple code :)"
- In reply to: Julie: "Re: Swapping"
- Next in thread: Herb Sutter: "Re: Swapping"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 16 Jul 2004 17:18:47 GMT
In comp.lang.c Julie <julie@nospam.com> wrote:
> Michael wrote:
>>
>> > Please describe (in code) a situation where two variables share the same memory
>> > location.
>> >
>> Dan you need to try stuff for yourself
>>
>> #include <stdio.h>
>>
>> int main(void){
>> int x=10, *p;
>> p=&x;
>> printf("%p, %p\n",(void *)p,(void *)&x);
>> return 0;
>> }
> You need to think a little harder:
> You have two variables: x and p. Are you saying that &x == &p? I sure hope
> not.
That is not what he is saying. You are failing to grasp that *p is a
variable. Perhaps this quote from page 45 of K&R2 will enlighten you:
"...The increment and decrement operators can only be applied
to variables..."
This, in my mind, would mean that *p can be considered a variable, at
least part of the time. Technically, of course, *p can hardly be
considered a variable when p does not contain the address of a valid
object.
-- Alex Monjushko (monjushko@hotmail.com)
- Next message: Thomas Matthews: "Re: help to read files"
- Previous message: Pavel Sorokin: "memory access error in some simple code :)"
- In reply to: Julie: "Re: Swapping"
- Next in thread: Herb Sutter: "Re: Swapping"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|