Chinaunix首页 | 论坛 | 博客
  • 博客访问: 340160
  • 博文数量: 59
  • 博客积分: 2000
  • 博客等级: 大尉
  • 技术积分: 646
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-14 12:09
文章分类

全部博文(59)

文章存档

2009年(2)

2008年(57)

我的朋友

分类: C/C++

2008-07-14 17:52:09

itoa是一个可以将整数转换为字符串的函数,配合textout函数可以方便的输出数字,使用方法如下:

用法:char *itoa(int   value,   char   *string,   int   radix);
将整数value转换成字符串存入string,   
radix为转换时所用基数(保存到字符串中的数据的进制基数2、8、10、16)

程序例:
  #include    
  #include 
  int main(void)    
  {    
        int  number   =   12345;    
        char string[25];     
        itoa(number, string,10);    
        printf("integer   =   %d   string   =   %s\n",   number,   string);    
        return   0;    
  }

阅读(11301) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

lizeliang.linux2008-08-16 20:03:07

在linux下没有itoa这个函数,我说老是编译不过。 linux下的字符转换函数只有: atof 字符串转换到浮点型数 atoi 字符串转换到整型数 atol 字符串转换到长整型数 ecvt 浮点型数转换到字符串,取四舍五入 fcvt 浮点型数转换到字符串,取四舍五入 gcvt 浮点型数转换到字符串,取四舍五入 strtod 字符串转换到浮点型数 strtol 字符串转换到长整型数 strtoul 字符串转换到无符号长整型数 toascii 将整形数转换合法的ASCII字符串