指针知识求解!
#include<iostream>using namespace std;
char *max(char *x, char *y);
void main()
{
char c1[10], c2[10];
char *s1, *s2;
s1 = c1;
s2 = c2;
cout << "请输入字符串1:" << endl;
cin >> c1;
cout << "请输入字符串2:" << endl;
cin >> c2;
cout << endl;
cout << max(s1, s2) << endl;
}
char *max(char *x, char *y)
{
if (strcmp(x, y) > 0)
return x;
return y;
}
问题:max函数中strcmp(x,y)比较的是两个地址吗?这个函数返回的是什么?