为什么参数为isdigit整数? [英] Why is parameter to isdigit integer?
问题描述
函数 std :: isdigit
是:
int isdigit(int ch);
返回值(如果字符是数字字符,则为非零值,否则为零).闻起来就像该函数是从C继承的,但是即使那样也不能解释为什么参数类型为 int
而不是 char
同时...
The return (Non-zero value if the character is a numeric character, zero otherwise.) smells like the function was inherited from C, but even that does not explain why the parameter type is int
not char
while at the same time...
如果ch的值不能表示为,则行为不确定unsigned char,不等于EOF.
The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.
是否有技术上的原因为何数字
采用 int
而不是 char
?
Is there any technical reason why isdigits
takes an int
not a char
?
推荐答案
原因是允许 EOF
作为输入.并且 EOF
是(来自此处):>
The reaons is to allow EOF
as input. And EOF
is (from here):
int类型和负值的EOF整数常量表达式
EOF integer constant expression of type int and negative value
这篇关于为什么参数为isdigit整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!