#include
#include
void swap(char a[100],char b[100]);
int main()
{
char str1[100],str2[100];
printf("input 1:");
gets(str1);
printf("input 2:");
gets(str2);
swap(str1,str2);
printf("str1:%s\nstr2:%s\n",str1,str2);
return 0;
}
void swap(char a[100], char b[100])
{
char t[100];
strcmp(t,a);
strcmp(a,b);
strcmp(b,t);
}
Swap这样写:
void Swap(char *str1, char *str2)
{
char temp[100];
strcpy(temp, str1);
strcpy(str1, str2);
strcpy(str2, temp);
}
下面函数定义把中括号去了