文章目录
atoi() : char*转int
ASCII to integer
#include <stdlib.h>
int atoi(const char *str)
atof():char*转double
ascii to float
#include <stdlib.h>
double atof(const char *str)
不提供异常处理机制。如果转换失败,它返回 0.0,无法区分空字符串和转换失败
atol():字符串转换成长整形
ascii to long
itoa():将整形转换成字符串
integer to ASCII
stof():字符串转float
float stof(const std::string& str, std::size_t* pos = 0);
strtof()
float strtof(const char* str, char** endptr);
gcvt
浮点型转换成字符串(四舍五入)
strtod
字符串转换成浮点型
strtol
字符串转换成长整形
strtoul
字符串转换成无符号长整形
toascii
将整形转换成合法的ASCII码字符
_ttoi
可以将CString转换成整形
int iValue = _ttoi(strValue) ;//将Cstring转换成int
_ttoi 函数是一个常用的转换函数,它可以将字符串转换为整数。这个函数在 ANSI 编码系统中被编译成 _atoi(),而在 Unicode 编码系统中编译成 _wtoi()
_itot_s
将int转换成char*