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

admin2020-06-16  28

问题 阅读下面程序,程序执行后的结果为(    )。
#include"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/3s3p777K
0

相关试题推荐
最新回复(0)