How to convert integer to string? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to convert integer to string?

I want to convert an integer say 89 to string "89". In python it could be done easily with str(). How to do this in C++

30th Sep 2016, 12:31 AM
AlphaCoder
AlphaCoder - avatar
3 Answers
+ 2
int a = 10; char *intStr = itoa(a); string str = string(intStr);
30th Sep 2016, 1:01 AM
Chakib Dabbek
Chakib Dabbek - avatar
0
std::string s = std::to_string(yourInt);
30th Sep 2016, 8:12 AM
Andrew Williams
Andrew Williams - avatar
0
Chakib, do i have to include anything before using the code.
30th Sep 2016, 11:38 AM
AlphaCoder
AlphaCoder - avatar