forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to convert int to string?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Crux



Joined: 25 May 2008
Posts: 10

PostPosted: Fri Jun 06, 2008 4:03 am    Post subject: How to convert int to string? Reply with quote

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
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Fri Jun 06, 2008 4:13 am    Post subject: Reply with quote

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
View user's profile Send private message
Crux



Joined: 25 May 2008
Posts: 10

PostPosted: Fri Jun 06, 2008 4:17 am    Post subject: Reply with quote

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
View user's profile Send private message
daaa57150



Joined: 17 Nov 2006
Posts: 28

PostPosted: Tue Jun 17, 2008 9:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
whistler



Joined: 04 Mar 2008
Posts: 40

PostPosted: Tue Jun 17, 2008 11:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Wed Jun 18, 2008 8:11 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group