在C++中用itoa要包含什么头文件?

如题所述

在C++中用itoa()要包含的头文件:# include <stdio.h>、# include <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个参数:第一个参数是要转换的数字,第二个参数是要写入转换结果的目标字符串,第三个参数是转移数字时所用的基数。

itoa并不是一个标准的C函数,它是Windows特有的,如果要写跨平台的程序,请用sprintf。

温馨提示:答案为网友推荐,仅供参考
相似回答