有以下程序 #include <stdio.h> int fun( char s[] ) { char *p = s; while( *p != 0 ) p++; return ( p-s ); } main() {

admin2021-04-28  24

问题 有以下程序
#include <stdio.h>
int  fun( char  s[] )
{  
    char  *p = s;
    while( *p != 0 )  p++;
    return ( p-s );
}
main()
{  
    printf("%d\n", fun("0ABCDEF") );  
}
程序运行后的输出结果是

选项 A、1
B、6
C、7
D、0

答案C

解析 本题考查字符串作为函数参数以及while语句,本题中传入字符串OABCDEF,然后执行fun后,就得到了该字符串中字符的个数,不包括结尾符,该字符串有7个字符,所以答案为C。
转载请注明原文地址:https://kaotiyun.com/show/Yktp777K
0

最新回复(0)