博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
嵌入式100题(027):char和int之间的转换
阅读量:4166 次
发布时间:2019-05-26

本文共 261 字,大约阅读时间需要 1 分钟。

char和int之间的转换

Char转int:

Char与int的相互转换,联想ASCII码,字符’0’对应的值为48,所以不能直接加减’’;

Char ch = ’9’;

int ch_int = ch – ’0’; //此时ch_int = 9;

int转char:

int i= 9;

char i_ch = i + ’0’;  //此时i_ch = ’9’

必须记住的几个ASCII值:

字符值ASCII值

’0’ = 48

’9’ = 57

’A’ = 65

’Z’ = 90

’a’ = 97

’z’ = 122

转载地址:http://txrxi.baihongyu.com/

你可能感兴趣的文章
python 寻找前5个默尼森数
查看>>
python2 type()函数 isinstance()函数
查看>>
python is 同一性运算符
查看>>
python basestring( )
查看>>
python 本地数据获取
查看>>
python write( )函数
查看>>
python read( )函数
查看>>
python readline()函数
查看>>
python readlines()函数
查看>>
python writelines()函数
查看>>
python 文件读写5个实例
查看>>
python 文件读写项目实践
查看>>
python的 os 和 shutil 模块
查看>>
python 如何反转序列
查看>>
python str.join()
查看>>
python 内置函数 reversed()
查看>>
python sort()方法
查看>>
python sorted()函数
查看>>
python reverse()方法
查看>>
Python sort( ) sorted( ) reverse( ) reversed( ) 总结
查看>>