• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Converting integers to strings in C++

EvilManagedCare

Senior member
The subject says it all. I have an variable that is an integer. I must manipulate how it will display on the screen. I am used to programming in Java, so I remember a host of methods that can help. What function in C++ converts integers to strings?

Thanks in advance.
 
I'm in the same boat, but IIRC there was an itoa() function part of most standard libraries that converted from an integer to a character array.
 
you can also use the stringstream class eg

#include <sstream>

std::stringstream strbuffer;

strbuffer << theint;

std::cout << strbuffer.str();
 
Originally posted by: dighn
you can also use the stringstream class eg

#include <sstream>

std::stringstream strbuffer;

strbuffer << theint;

std::cout << strbuffer.str();

 
Back
Top