Such a little program, with so many problems!

> #include<stdio.h>
> #include<conio.h>

Non-standard header.

> void main()

main always returns int

> {
> int a=2,b=3;
> swap(a,b);

Passing int to a function that expects int*. You probably meant to use
swap (&a, &b)

> swap(int *x,int *y)
> {
> int t;
> t=*x;

Here you're dereferencing an int as a pointer, this is almost sure to
crash your program.

> *x=*y;
> *y=t;
> printf("%d%d",x,y);

%d expects an int, you're passing a pointer to int.

This program not only does not compile, it is wrong, and even if it
doesn't crash it won't give the expected output. Also, as others have
pointed out you gain nothing  by using pointers, as you're still using
a temporary for the swap. The pointers only add confusion (and I'm not
really sure you're really familiar with the concept of pointers).

Please refrain from posting solutions to the group if you are not sure
your solution is correct.

--
Tamas Marki

Reply via email to