#include <stdio.h>
#include <string.h>
void StanfordSwap(void *vp1, void *vp2, int size)
{
char buffer[size];
memcpy(buffer,vp1,size);
memcpy(vp1,vp2,size);
memcpy(vp2,buffer,size);
}
#define EvineSwap(thing1,thing2,Type) \
{ \
Type temp = thing1; \
thing1 = thing2; \
thing2 = temp; \
}
#define EvineOtherSwap_Define(Type) \
void EvineOtherSwap_##Type(Type *thing1, Type *thing2) \
{ \
Type temp = *thing1; \
*thing1 = *thing2; \
*thing2 = temp; \
}
EvineOtherSwap_Define(int)
EvineOtherSwap_Define(char)
int main() {
int apple = 4;
int pear = 70;
EvineOtherSwap_int(&apple,&pear);
//EvineSwap(apple,pear,int);
//StanfordSwap(&apple,&pear,sizeof(int));
printf("apple: %i\n",apple);
printf("pear: %i\n",pear);
return 0;
}