VS2017 solutions encountered in the transfer function from string to const char * does not exist

Using the c_str () function
c_str function return value is const char *. 

the c_str () function returns a pointer pointing to regular C string, this string with the content of the same string.
This is for compatibility with c language, no language in the c-string type, it is necessary to convert the object into a string by string patterns member function c in the c_str string class object (). 

For chestnut:

String st = "insert into chuang values ('" + vos[0] + "', '" + vos[1] + "','" + str_time + "')";
const char* sql1 = st.c_str();

 

 

Guess you like

Origin www.cnblogs.com/ming-4/p/11544441.html