问题
单项选择题
下面程序输出的结果是( )。 #include<iostream> using namespace std; int fuc (char *x); int main(){cout<<fuc("hello")<<endl;return 0; } int fuc(char *x){char *y=x;while(*y! ='\0')y++;return(y-x); }
A.5
B.6
C.0
D.语法错误,不能输出结果
答案
参考答案:A
解析: 函数fuc()的功能是计算字符串x的长度,因此程序的输出是5。