Cannot convert int to int *

#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 get .. cann't convert int to int * ...

can someone tell me why so. and how to solve it Regards.

hoping for a quick and positive response.

+3
source share
1 answer

Your call swap()should include ampersands:

swap(&a,&b);

swapexpects pointers int, so you need to take the address aand bduring transmission.

+20
source

Source: https://habr.com/ru/post/1763505/


All Articles