阅读下面程序,程序执行后的结果为( )。 #inc1ude "stdio.h" main() {char *str="abcdefghijklmnopq"; while(*str++! =’e’); print

admin2021-04-28  22

问题 阅读下面程序,程序执行后的结果为(    )。
    #inc1ude "stdio.h"
    main()
    {char *str="abcdefghijklmnopq";
    while(*str++! =’e’);
    printf("%c\n",*str);
    }

选项 A、f
B、a
C、e
D、q

答案A

解析 本题考查的是取内容运算符“*”和自加运算符“++”的优先级问题。由于“++”的优先级高于“*”,所以题干中“*str++!=’e’”,即“*(str++)!=’e’”,当str指向字符“’e"’时,while循环的条件不成立,但“str”已经进行了自加指向了字符“’f’”,所以“*str”输出字符“’f’”。
转载请注明原文地址:https://kaotiyun.com/show/DHtp777K
0

最新回复(0)