int to string code in wxwidgets
I've been looking for a method that can cast int type to string type
Here are some solution you can use
For console mode by standard C
1. int sprintf( char *buffer, const char *format [, argument] ... );
ex:
char *str;
int num = 66;
sprintf(str, “%d”, num);
printf(”str = %s\n”, str);
2. char *_itoa( int value, char *string, int radix );
ex:
#include <stdlib.h>
char buffer[20];
int i = 1234;
_itoa( i, buffer, 10 );
string s(buffer);
3. Using boost library to cast. Must download boost C++ libraries first.
ex:
#include <boost\lexical_cast.h>
int i;
std::string str = boost::lexical_cast<std::string>(i);
4. In wxwidgets GUI application from here
ex:
long number; // this can be any number type such as int or double ,etc...
wxString stringnumber = wxString::Format(wxT("%d"), (int)number);
No comments:
Post a Comment