string StringToUpper(string strToConvert)
{
//change each element of the string to upper case
for(unsigned int i=0;i<strToConvert.length();i++)
{
strToConvert[i] = toupper(strToConvert[i]);
}
return strToConvert;//return the converted string
}
string StringToLower(string strToConvert)
{
//change each element of the string to lower case
for(unsigned int i=0;i<strToConvert.length();i++)
{
strToConvert[i] = tolower(strToConvert[i]);
}
return strToConvert;//return the converted string
}
วันจันทร์ที่ 13 กรกฎาคม พ.ศ. 2552
C Convert cases of strings (tolower/toupper)
Two functions, used to convert c++ strings from upper case to lowercase and vice versa. Each takes a string argument, and returns the converted string. Please note that parameters should be validated before passing them to the functions.
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น