#include "stdio.h"
#include "conio.h"
void swap(int *x,int *y);
void main()
{
int a=10,b=20;
swap(a,b);
printf("value of a=%d and b=%d");
getch();
}
void swap(int *x,int *y)
{
if(x!=y)
{
*x ^= *y;
*y ^= *x;
*x ^= *y;
}
}
// I'm getting .. cann't convert int to int * ...
can anybody tell me why so . and how to solve it regards.
hoping for quick and positive response.
Your call to swap()
should include ampersands:
swap(&a,&b);
swap
is expecting pointers to int
, so you need to take a
and b
's addresses when passing them in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With