-
Converting a
char *
to int
.
// function to convert char * to int
int returnInt( char i[] )
{
int integer;
integer = atoi(i); // must include cstdlib (stdlib.h)
return integer;
}
-
Converting a
char *
to double
.
// function to convert char * to double
double returnDouble(char i[])
{
double floaty;
floaty = atof(i); // must include cstdlib (stdlib.h)
return floaty;
}
-
Converting a
int
to CString
.
// function to convert int to CString
CString returnCString( int i )
{
CString s;
s.Format( ("%-15d"), i );
return s;
}
-
Converting a
double
to CString
.
// function to convert double to CString
CString returnCString( double i )
{
CString s;
s.Format( ("%-14.2f"), i );
return s;
}
-
For more weird conversions and lots of C++ stuff go to
http://www.cplusplus.com/ref/