在C语言中,可以使用sprintf()函数将数字转换成字符。以下是一个示例代码:
#include <stdio.h>
#include <stdlib.h>
int main() {
int num = 12345;
char str[10];
sprintf(str, "%d", num);
printf("Number as string: %s\n", str);
return 0;
}
在上面的示例中,我们使用sprintf()函数将整数num转换成字符数组str。然后我们可以通过printf()函数打印出转换后的字符数组。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:c语言字符转换成数字怎么实现