在C和C+中将char转换为int如何转换char转到int在C和C+中?
3 回答
鸿蒙传说
TA贡献1865条经验 获得超7个赞
char a = 'a';int ia = (int)a; /* note that the int cast is not necessary -- int ia = a would suffice */
'0' -> 0
, '1' -> 1
char a = '4';int ia = a - '0';/* check here if ia is bounded by 0 and 9 */
Smart猫小萌
TA贡献1911条经验 获得超7个赞
int
int
char
char
int
.
char c = 'a'; // narrowing on Cint a = c;
- 3 回答
- 0 关注
- 1809 浏览
添加回答
举报
0/150
提交
取消