linux下将整数转化为字符串用法(itoa()函数,sprintf()函数)

1.1在linux系统下,没有itoa()函数,只有atoi()函数。其中itoa()函数的头文件如下:

#include <stdlib.h>

1.2想要实现将整数转化为字符串,可以用如下函数实现。

sprintf(str, "%d", rand());//将整形变量转换为字符串变量    rand()表示随机数,0-42亿范围内


1.3程序调用运行后的结果图,如下图所示:




参考内容:

https://blog.csdn.net/xueyushenzhou/article/details/42705525

猜你喜欢

转载自blog.csdn.net/naibozhuan3744/article/details/80623298