交换俩字符串

1 void swap(char *p,char *q)
2 {
3     char tmp[100];
4     strcpy(tmp,p);
5     strcpy(p,q);
6     strcpy(q,tmp);
7 }

 或者

 1 void swap(char *p,char *q)
 2 {
 3     char tmp;
 4     int i,len=7;
 5     for(i=0;i<len;i++){
 6         tmp=*(p+i);
 7         *(p+i)=*(q+i);
 8         *(q+i)=tmp;
 9     }
10 }
原文地址:https://www.cnblogs.com/shixinzei/p/12443868.html