一 字符串转数字
1.CRT函数 (需要的头文件 <stdlib.h> <math.h> <wchar.h>)
ASCII | UNICODE | TCHAR | VS2005 | |
int | atoi | _wtoi | _tstoi _ttoi |
_atoi_l _wtoi_l |
long | atol | _wtol | _tstoi _ttoi |
_atoi_l _wtoi_l |
__int64 | _atoi64 | _wtoi64 | _tstoi64 _ttoi64 |
_atoi64_l _wtoi64_l |
float | _atoflt _atoflt_l |
|||
double | atof | _wtof | _tstof _ttof |
_atof_l _wtof_l _atodbl _atodbl_l |
long double | _atoldbl _atoldbl_l |
2.使用sscanf 头文件<stdio.h>
sscanf() 从一个字符串中读进与指定格式相符的数据。
原型:
int sscanf( const char *buffer,const char *format [,argument ] ... );
int scanf(const char *format [,argument]... );
其中参数 buffer:输入存储的数据;format:格式控制字符串
sscanf与scanf类似,都是用