On Tue, Feb 16, 2010 at 9:56 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.
[..]
> What I meant was that they used the values of the ints as the values
> for the pointers from the main() body:
>
> int a=2,b=3;
> swap(a,b);
>
> Dereferencing that will attempt to access memory location that is not
> accessible to the program, thus the crash.
>
> Or am I completely misunderstanding your comment?

They're still dereferencing a pointer, _in_the_function_. That's what
the function definition says x and y are.

What the function is being passed in this instance (and where you
should have put your comment for me to notice it) is where the problem
lies, not in the function itself ;)

Well one of the problems anyway. I think you covered most of the others :D

-- 
PJH

http://shabbleland.myminicity.com/env
http://www.chavgangs.com/register.php?referer=9375

Reply via email to