On Tue, Feb 16, 2010 at 9:23 PM, Tamas Marki <[email protected]> wrote:
[...]
>> swap(int *x,int *y)
>> {
>> int t;
>> t=*x;
>
> Here you're dereferencing an int as a pointer,
No they're not.
> this is almost sure to crash your program.
There's actually nothing wrong with what they're doing there - x was
passed in as a pointer, *x yields the value of what it points to.
>> *x=*y;
>> *y=t;
>> printf("%d%d",x,y);
>
> %d expects an int, you're passing a pointer to int.
That comment, however, /is/ correct - they should be using
printf("%d %d",*x,*y);
( Or if I were to assume they actually _meant_ to pass x and y, they
should be using
printf("%p %p",x,y);
)
--
PJH
http://shabbleland.myminicity.com/env
http://www.chavgangs.com/register.php?referer=9375