The ASCII value for character '0' is 48.

    Choose the execution result of following code.

#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    char a='1', b = '2';
    printf("%c,", b);
    printf("%d\n",b - a );
    
    return 0;
}


A. 3,1   B. 50,1   C. 2,1   D. 1,50

答案是(C), 第一個printf印出%c字元格式所以是2, 第二個printf%d為整數格式所以得到1

 

arrow
arrow
    文章標籤
    面試考古題
    全站熱搜

    Will 發表在 痞客邦 留言(0) 人氣()