为什么结果是44? [英] Why the result is 44 ?

查看:71
本文介绍了为什么结果是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);

}

解决方案

A char holds an ASCII character code, from 0 to 256 (1 byte). Adding up 100 and 200 results in 300, which is too big for one byte, so it overflows and will store 300 % 256 = 44 in c.


这篇关于为什么结果是44?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆