|
|
#1 |
|
Legs sold separately.
Moderator
Join Date: Aug 2004
Location: In a robot, destroying Tokyo.
Posts: 4,775
|
In order to not unfairly hijack Ducky's thread, I thought I'd create a new topic for me to ask my fairly-regular questions on how to do stuff in C++.
Firstly, is there a built-in function for converting an integer to a string? If not, I could always try to write one myself, but a ready-made function would be very helpful. |
|
|
|
|
|
#2 |
|
Veteran Programmer
|
As far as I know, there isn't, but this should work well. Put it in a file, say num2string.h
PHP Code:
PHP Code:
|
|
|
|
|
|
#3 |
|
Marshmallow Head
The Boss
Join Date: Jun 2003
Location: Anza, CA
Posts: 6,183
|
But there is... sprintf!
|
|
|
|
|
|
#4 |
|
Veteran Programmer
|
Ah yes, my solution is for numbers to words. If you just need character representations, Jamul's idea is best.
Code:
sprintf(buffer,"%d",num); |
|
|
|
|
|
#5 |
|
King of the pond!
|
Aww...Atkins...Jamul posted in your thread. Lucky guy. LOL
-Ducky (VENI, VIDI, ROLEX...I came, I saw, - what time it was!)
__________________
Mallard Memory 3 and Duck Wars --- Stopped Learning new C++ programming library now. |
|
|
|
|
|
#6 |
|
Legs sold separately.
Moderator
Join Date: Aug 2004
Location: In a robot, destroying Tokyo.
Posts: 4,775
|
Oh, cool! I didn't realise you could print to something other than the screen. Thanks.
|
|
|
|
|
|
#7 | |
|
King of the pond!
|
Quote:
- Ducky (VCRs are irrelevant. - Locutus of RCA)
__________________
Mallard Memory 3 and Duck Wars --- Stopped Learning new C++ programming library now. |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
