Convert char to const char * c++

How can i convert a char to const char* in c++
When i try to convert it i get this error:
invalid conversion from char to const char *
HaniDaherAsked:
Who is Participating?
 
HaniDaherConnect With a Mentor Author Commented:
we can use std::string(size_t , char ) constructor
string a = std::string(1 , str[0]);

Thank you,
well you are most welcome.
0
 
ZoppoCommented:
JFI: I would propose to do it directly without creating a copy, that's faster:

string a(1 , str[0]);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.