I want to change the int to a string

Asked 1 years ago, Updated 1 years ago, 75 views

Not the way I know it Please tell me the easiest way to change the int type to string!

//1.
int a = 10;
char *intStr = itoa(a);
string str = string(intStr);


//2.
int a = 10;
stringstream ss;
ss << a;
string str = ss.str();

string c++ int type-conversion

2022-09-21 23:21

1 Answers

0 of the x c++ std :: stoi , :: to std string the ?

std::string s = std::to_string(42);
std::string s = std::to_stoi(42);

You can use it with .


2022-09-21 23:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.