尝试把函数形参改成char*&格式但运行结果没有变化
{
char*s;
s = s1;
s1 = s2;
s2 = s;
}
int main()
{
char c[] = "teacher";
char d[] = "student";
char* e = c;
char* f = d;
const char* i = "teacher";
const char* j = "student";
swap(e, f);
cout << c << d << endl;
swap(c, d);
cout << c << d << endl;
swap(i, j);
cout << i << j << endl;
return 0;
}
运行结果teacherstudent
studentteacher
studentteacher