DEV Community


Char to String C++ how to convert string to char c++ ?

My name is Angular King. I'm a full-stack developer, entrepreneur and owner of Pakainfo. I live in India and I love to write
・1 min read

Today, We want to share with you convert char to string c++.In this post we will show you char to string c++, hear for c++ string we will give you demo and example for implement.In this post, we will learn about char to int with an example.

1. std::string constructor

easy way to solution will be to use data string class fill data c++ constructor transform your main string (size_t n, char c); which fills the string with n copies of character c.



int main()
char c = 'A';

// apply string class fill c++ constructor transform

std::string s(1, c);
std::cout << s << '\n';

return 0;
Enter fullscreen mode Exit fullscreen mode


You can visit my Article with More Examples : click here

Discussion (0)