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

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -