Bradbury 2020. 8. 28. 19:51
728x90

string to char * : str_cstr();

string to char๋ฐฐ์—ด

char cstr[100];
string str = "hello";
strlen(cstr, str.c_str());

 

char ๋ฐฐ์—ด to string

char *cstr = "hello";
string str = cstr;

char to int, float, long : atoi, atof, atol (ํ—ค๋” cstdlib)

string to int : 

string str = "100";
int num;
num = atoi(str.c_str());

int to string : to_string()

int num = 10;
string str;
str = to_string(num);
728x90