_itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明
2017-07-18 11:40
666 查看
原文:http://www.cnblogs.com/lidabo/archive/2012/07/10/2584706.html
_itoa
功能:把一整数转换为字符串
用法:char * _itoa(int value, char *string, int radix);
详细解释: _itoa是英文integer to array(将int整型数转化为一个字符串,并将值保存在数组string中)的缩写.其中value为要转化的整数, radix是基数的意思,即先将value转化为radix进制的数,之后再保存在string中.
备注:该函数的头文件是"stdlib.h"
程序例:
#include <stdlib.h>
#include <stdio.h>
int main()
{
int number = 123456;
char string[25];
_itoa(number, string, 10);
printf("integer = %d string = %s\n", number, string);
return 0;
}
注释:编译系统:VC++6.0,TC不支持。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/bufrfish/archive/2008/11/03/3209167.aspx
atoi函数
原型:int atoi( const char *string );
ASCII to integer
作用:将字符串转为integer类型
atof函数
原型:double atof( const char *string );
ASCII to float
作用:将字符串转为double类型
对于以上函数,若字符串无法转化为合法的数值类型,函数将返回0 。
使用范例(来自MSDN):
#include <stdlib.h>
2#include <stdio.h>
3
4void main( void )
5
Code
输出:
base 10: -1 (2 chars)
base 9: 12068657453 (11 chars)
base 8: 37777777777 (11 chars)
base 7: 211301422353 (12 chars)
base 6: 1550104015503 (13 chars)
base 5: 32244002423140 (14 chars)
base 4: 3333333333333333 (16 chars)
base 3: 102002022201221111210 (21 chars)
base 2: 11111111111111111111111111111111 (32 chars)
base 10: -1 (2 chars)
base 9: 12068657453 (11 chars)
base 8: 37777777777 (11 chars)
base 7: 211301422353 (12 chars)
base 6: 1550104015503 (13 chars)
base 5: 32244002423140 (14 chars)
base 4: 3333333333333333 (16 chars)
base 3: 102002022201221111210 (21 chars)
base 2: 11111111111111111111111111111111 (32 chars)
_itoa
功能:把一整数转换为字符串
用法:char * _itoa(int value, char *string, int radix);
详细解释: _itoa是英文integer to array(将int整型数转化为一个字符串,并将值保存在数组string中)的缩写.其中value为要转化的整数, radix是基数的意思,即先将value转化为radix进制的数,之后再保存在string中.
备注:该函数的头文件是"stdlib.h"
程序例:
#include <stdlib.h>
#include <stdio.h>
int main()
{
int number = 123456;
char string[25];
_itoa(number, string, 10);
printf("integer = %d string = %s\n", number, string);
return 0;
}
注释:编译系统:VC++6.0,TC不支持。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/bufrfish/archive/2008/11/03/3209167.aspx
atoi、atof、_itoa、_itow 函数使用
atoi、atof、itoa、itow函数是windows平台下实现字符串与数值相互转换的函数。Linux平台下请使用标准库中的sprintf与sscanf函数。atoi函数
原型:int atoi( const char *string );
ASCII to integer
作用:将字符串转为integer类型
atof函数
原型:double atof( const char *string );
ASCII to float
作用:将字符串转为double类型
对于以上函数,若字符串无法转化为合法的数值类型,函数将返回0 。
使用范例(来自MSDN):
#include <stdlib.h>
2#include <stdio.h>
3
4void main( void )
5
Code
输出:
base 10: -1 (2 chars)
base 9: 12068657453 (11 chars)
base 8: 37777777777 (11 chars)
base 7: 211301422353 (12 chars)
base 6: 1550104015503 (13 chars)
base 5: 32244002423140 (14 chars)
base 4: 3333333333333333 (16 chars)
base 3: 102002022201221111210 (21 chars)
base 2: 11111111111111111111111111111111 (32 chars)
base 10: -1 (2 chars)
base 9: 12068657453 (11 chars)
base 8: 37777777777 (11 chars)
base 7: 211301422353 (12 chars)
base 6: 1550104015503 (13 chars)
base 5: 32244002423140 (14 chars)
base 4: 3333333333333333 (16 chars)
base 3: 102002022201221111210 (21 chars)
base 2: 11111111111111111111111111111111 (32 chars)
相关文章推荐
- _itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明
- _itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明
- _itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明
- _itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明
- _itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明
- _itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明
- _itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明
- C++中,int和char互转函数_itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明
- _itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明
- _itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明
- _itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明
- _itoa atoi、atof、itoa、itow _itoa_s 类型转换使用说明
- MFC数据类型转换 _itoa atoi、atof、itoa、itow _itoa_s
- 类型转换 atoi, itoa, atof
- C++ 类型转换 atoi atol atof <stdlib.h>, itoa ftoa char <---> string
- 关于转换的问题,平时用到一些 内置类型之间的 转换方法如atoi atof itoa sprintf 等 istrstream ostrstream strstream【2013.10.21】
- stringstream/snprintf/sscanf/atoi/itoa数据类型转换比较
- (1411)实现字符串与整数的相互转换(不使用itoa和atoi)
- 数字转字符串(string)扩充说明及简单写数字和字符串转换代码(正式比赛的itoa和atoi用不了)
- VC常用数据类型转换使用