转:(记录)C语言中的itoa()函数的用法解析
转:(记录)C语言中的itoa()函数的用法解析
本博客转自文章:.html
C语言中的 itoa() 函数的用法:
C语言提供了几个标准库函数,可以将任意类型 (整型、长整型、浮点型等) 的数字转换为字符串。
itoa() : 将整型值转换成字符串
以下是用itoa()函数将整数转换为字符串的一个例子:
# include <stdio.h>
# include <stdlib.h> //该函数的头文件是<stdlib.h>
void main (void)
{
int num = 100;
char str[25];
itoa(num, str, 10);
printf("The number 'num' is %d and the string 'str' is %s. \n" ,
num, str);
}
itoa()函数有3个参数:第一个参数是要转换的数字,第二个参数是要写入转换结果的目标字符串,第三个参数是转移数字时所用 的基数。在上例中,转换基数为10。10:十进制;2:二进制...