阅读下面程序,程序执行后的结果为( )。 #include “stdio.h” mam() { char*str=:“abcdefghklmnopq"; while(*str++!=‘e’); printf(“

admin2021-06-15  23

问题 阅读下面程序,程序执行后的结果为(    )。
   #include “stdio.h”
    mam()
    {  char*str=:“abcdefghklmnopq";
    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/Cgtp777K
0

最新回复(0)