请教操作符
#include "stdio.h "
main () {
int q,temp;
char apple;
temp = sizeof(int) * q;
apple = (char) temp;
printf( "The result is: %d\n ",apple);
}
输出0
#include "stdio.h "
main () {
int q,temp;
char apple;
temp =0;
q =10;
temp = sizeof(int) * q;
apple = (char) temp;
printf( "The result is: %d\n ",apple);
}
输出20
怎么一会事啊。请教 !
[解决办法]
#include "stdio.h "
main () {
int q,temp;
char apple;
temp =0;
q =10;
temp = sizeof(int) * q;
apple = (char) temp;
printf( "The result is: %d\n ",apple);
}
一般sizeof(int)=4或者2,要看编译器和系统,明显你这里是2所以出20
[解决办法]
TC2.0 是16位的,sizeof(int)=2,所以 apple=2*q=2*10=20