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
文章標籤
全站熱搜