下面程序输出的结果是( )。 #include<iostream> using namespace std; int fuc (char *x); int main(){ cout<<fuc("hello")<<

admin2013-02-27  19

问题 下面程序输出的结果是(    )。    #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、语法错误,不能输出结果

答案1

解析 函数fuc()的功能是计算字符串x的长度,因此程序的输出是5。
转载请注明原文地址:https://kaotiyun.com/show/dENp777K
0

最新回复(0)