49
是整数1的ASCII值。看起来您需要将字节值转换回char
s,然后转换为int
s。
这里有一个要引用的ASCII表:klcconsulting.net/ascii.htm查看十进制值49
,看它是ASCII字符1
的十进制值。如果用户值为10
,则应返回两个字节{49, 48}
,第一个用于1
,第二个用于0
。
So, I've had to deal with a similar problem to this before. As an int, those are the correct results, but the literal version of it is +48 (if you stay within 0-9) because that is where the numbers in the character code begins. If you subtract 48 you will get your answer within the first 10 digits, once you get over that it becomes a little more crazy to get the information.