| View previous topic :: View next topic |
| Author |
Message |
Crux
Joined: 25 May 2008 Posts: 10
|
Posted: Fri Jun 06, 2008 4:03 am Post subject: How to convert int to string? |
|
|
| I've seen several examples of this, but none that work with the PSP development environment (includes are not there). Does anyone know a sure fire way of doing this? Thanks, for ANY help you can give me. |
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Fri Jun 06, 2008 4:13 am Post subject: |
|
|
This isn't really PSP related.
I'm unsure what you mean by converting an int to a string...
Do you mean like so?
| Code: | | sprintf(char_array, "%d", someint); |
Or do you mean so that '1' shows as 'one', '2' as 'two' etc?
The noob bashers are gonna come get you, btw :p |
|
| Back to top |
|
 |
Crux
Joined: 25 May 2008 Posts: 10
|
Posted: Fri Jun 06, 2008 4:17 am Post subject: |
|
|
Lol thats fine I can hear them coming. But like I believe you've said to many before, we all start somewhere. I do try to contribute back to the forum, but my expertise is VERY limited, but I hope to one day offer as much back as many as you do.
With that said I'll go attempt the code thank-you! |
|
| Back to top |
|
 |
daaa57150
Joined: 17 Nov 2006 Posts: 28
|
Posted: Tue Jun 17, 2008 9:32 pm Post subject: |
|
|
I wrote one that can convert any number type to a string:
| Code: |
#include <sstream>
#include <string>
#include <iostream>
using namespace std;
template<class T> inline string toString(T number)
{
ostringstream ost;
ost << number;
return ost.str();
}
|
I think this will need you to have -lstdc++ added to the libs in your makefile. |
|
| Back to top |
|
 |
whistler
Joined: 04 Mar 2008 Posts: 40
|
Posted: Tue Jun 17, 2008 11:13 pm Post subject: |
|
|
google itoa (integer to ascii)
edit nvm i've grepped the headers and it looks like this function may not be supported |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Wed Jun 18, 2008 8:11 am Post subject: |
|
|
Of course itoa is not remotely standard so you would expect to find it.
Still nothing comes quite close to this fucktard where he claims sprintf cannot print anything but base 10 numbers and proceeds to present increasingly stupid ways of doing what you just use sprintf for.
http://www.jb.man.ac.uk/~slowe/cpp/itoa.html
Truly unbelievable. |
|
| Back to top |
|
 |
|