#include #include #include intgetmax(inta,intb){if(a>b){returna;}else{returnb;}}voidswap(void*a,void*b){void*tmp;intla=sizeof(a);intlb=sizeof(b);intmax=getmax(la,lb);void*t=(void*)malloc(max);if(t==NULL){printf("%s\n","错误");exit(0);}memcpy(t,a,max);memcpy(a,b,max);memcpy(b,t,max);printf("%d\n",sizeof(a));printf("%d\n",sizeof(b));printf("%d\n",max);free(t);}intmain(){char*str="123";char*str2="456";swap((void*)str,(void*)str2);printf("%s\n",str);printf("%s\n",str2);}
蛊毒传说
慕娘9325324
相关分类