/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <iostream>
using namespace std;
void swap (void *, void *, int);
int
main ()
{
int a = 5, b = 3;
double c = 6.6, d = 2.2;
swap (&a, &b, sizeof (int));
swap (&c, &d, sizeof (double));
cout << "a=" << a << " b=" << b << endl;
cout << "c=" << c << " d=" << d;
return 0;
}
void
swap (void *x, void *y, int size)
{
int i;
char *p = (char *) x;
char *q = (char *) y;
char tmp;
for (i = 0; i < size; i++, p++, q++)
{
tmp = *p;
*p = *q;
*q = tmp;
}
}