Easy C++ question

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
convert the integer into a string.

Many methods exist. sprintf, itoc, etc

Using sprintf would allow you to use formatting to place the string and integer in the order that you desire.
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
you can send both of them into a stringstream with << and then get the resulting string as output.
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Originally posted by: oog
you can send both of them into a stringstream with << and then get the resulting string as output.

One of my favorites for building SQL queries.
 

desteffy

Golden Member
Jul 16, 2004
1,911
0
0
Originally posted by: oog
you can send both of them into a stringstream with << and then get the resulting string as output.

OMG thanks i never knew about the stringstream class. I looked it up in my book and my problems are solved.
 

desteffy

Golden Member
Jul 16, 2004
1,911
0
0
Originally posted by: EagleKeeper
convert the integer into a string.

Many methods exist. sprintf, itoc, etc

Using sprintf would allow you to use formatting to place the string and integer in the order that you desire.

Thanks also, these were the kinds of things i was trying before but having trouble with.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
sprintf is legacy C stuff (won't work with std::string), not to mention a very common source of buffer overflows.

itoc must be some platform-specific thing.

stringstream is the way!