Cstring, char *, String, Int, _ bstr_t, ctime, and coledatetime are converted to each other to determine whether a string is a floating point number.
# Include
Using namespace STD;
# Include
{
Cstring strcstring = "ABC ";
Char strchar [256], * pstr;
Pstr = (lpstr) (lpctstr) strcstring; // cstring ----> char *
Strcpy (strchar, (lpstr) (lpctstr) strcstring); // cstring ----> char []
_ Bstr_t strbstr = pstr; // char * ----> _ bstr_t
Wchar * strwchar = strbstr; // B _str_t ---> Unicode
Strbstr = strwchar;
Pstr = strbstr; // Unicode ----> char *
Strcstring = "10 ";
Int istr = atoi (lpstr) (lpctstr) strcstring); // cstring, char [], char * ------> int
Strcstring. Format ("% d", istr); // int -----> cstring
Sprintf (strchar, "% d", istr); // int -----> char []
Pstr = new char [256]; // string request Space
Strcpy (pstr, "ABC"); // string value assignment
Delete [] pstr; // string release
String strstring = "ABC ";
Pstr = (char *) strstring. c_str (); // string ----> char *
Strcstring = "6:24:37"; // cstring ---> coledatetime
Colevariant vtime (strcstring );
Vtime. changetype (vt_date );
Coledatetime time4 = vtime;
Coledatetime time1 (1977,4, 16,2,); // coledatatime ---> ctime
Systemtime receivime;
Varianttimetosystemtime (time1, & systime );
Ctime TM (systime );
Time_t time2 = TM. gettime (); // ctime ---> time_t
Coledatetime time3 (time2); // time_t ---> coledatetime
// Determine whether the string is of a certain type
Cstring svalue ("123.1 ");
Colevariant vvalue (svalue );
Bool bstrisfloat = (succeeded (variantchangetype (& vvalue, & vvalue, 0, vt_r8) & svalue. Find ('.')! =-1 );
If (bstrisfloat)
{
Afxmessagebox ("Floating Point ");
}
}