int score = 10;
char str[20];
memset(str, 0, sizeof(str)); //清空数组
sprintf(str, "%d\n", score); //将int转化并保存至str中
printf("%s", str); //打印为string
char name[20] = "str";
sprintf(str, "%s%d", name, score); //拼接
printf("%s", str);
C语言 使用sprintf int转字符串和拼接
于 2022-08-29 23:09:36 首次发布