c++ - Convert string to const char* issue -
this question has answer here:
string str1 = "hello"; const char* string1 = str1;
i error..
cannot convert ‘std::string {aka std::basic_string}’ ‘const char*’ in initialization
how cast string const char*
thanks helping
how cast string const char*?
use std::string::c_str() function, returns non-modifiable standard c character array version of string.
const char* string1 = str1.c_str();
Comments
Post a Comment