how to convert character to string in c++ code example
Example 1: c++ cast char to string
// example
char sczName[] = {"Jakes"};
std::string strName = std::string(sczName);
/* SYNTAX
#include <string>
std::string(<char-to-convert>)
*/
Example 2: c++ char to string
#include <iostream>
using namespace std;
int main()
{
char c = 'l';
string str;
str.push_back(c);
}
Example 3: why convert char* to string c++
char *cStr = "C++";
std::string Str = std::string(cStr);