Converting integers to strings in C++

EvilManagedCare

Senior member
Nov 6, 2004
324
0
0
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.
 

mundane

Diamond Member
Jun 7, 2002
5,603
8
81
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.
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
you can also use the stringstream class eg

#include <sstream>

std::stringstream strbuffer;

strbuffer << theint;

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

oog

Golden Member
Feb 14, 2002
1,721
0
0
Originally posted by: dighn
you can also use the stringstream class eg

#include <sstream>

std::stringstream strbuffer;

strbuffer << theint;

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

 

homercles337

Diamond Member
Dec 29, 2004
6,340
3
71
Originally posted by: dighn
you can also use the stringstream class eg

#include <sstream>

std::stringstream strbuffer;

strbuffer << theint;

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

Beat me to it...