1. Determine whether a string contains non-numeric characters
# Include <string>
Bool ischar (string judstr)
{
Char szbuf [2];
While (judstr. Length ()! = 0)
{
Strcpy_s (szbuf, (judstr. substr (0, 1). c_str ());
Int c = (INT) (szbuf [0]);
Judstr = judstr. substr (1, sizeof (judstr) + 1 );
// If any of the string is character, then this string is a character, return true.
If (isalpha (c ))
{
Return true;
}
}
// If all of the string is number, the string is number, return true.
Return false;
}
2. Convert all characters in a string to uppercase.
# Include <string>
String uperstring (string Str)
{
Char szbuf [2];
String restr = "";
String temp_word = "";
While (Str. Length ()! = 0)
{
Strcpy_s (szbuf, (Str. substr (0, 1). c_str ());
Int c = (INT) (szbuf [0]);
Temp_word = toupper (C );
STR = Str. substr (1, sizeof (STR) + 1 );
Restr = restr + temp_word;
}
// If all of the string is number, the string is number, return true.
Return restr;
}
3. Convert string to Char
Char szbuf [2];
Strcpy_s (szbuf, (pointer-> word). substr (0, 1). c_str ());