为什么结果是44? [英] Why the result is 44 ?
本文介绍了为什么结果是44?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道为什么结果是44?
我尝试了什么:
#include < stdio.h >
int main(){
unsign char a,b,c;
a = 100;
b = 200;
c = a + b;
printf( %d,c);
}
解决方案
char
持有ASCII字符代码,从0
到256
(1个字节)。加起来100和200导致300,这对于一个字节来说太大了,所以它溢出并且将在c <中存储
300%256 = 44
/ code>
I don't undersand why the result is 44 ?
What I have tried:
#include <stdio.h>
int main(){
unsign char a,b,c;
a=100;
b=200;
c=a+b;
printf("%d", c);
}
解决方案
Achar
holds an ASCII character code, from0
to256
(1 byte). Adding up 100 and 200 results in 300, which is too big for one byte, so it overflows and will store300 % 256 = 44
inc
.
这篇关于为什么结果是44?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文