假设我有一个整数,我想将它转换为一个字符?在 C++ 中有哪些方法可用或我应该使用哪些方法?例如,引用下面给定的代码
#include <bits/stdc++.h>
using namespace std;
int main
{
int i = 1;
// Say I want to convert 1 to a char '1';
// How do I achieve the following in C++
}
最佳答案
char c = digit + '0' ;
它将完成您的工作。
关于c++ - 如何在C++中将整数转换为字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68875446/