What's Here?
- Members: 86,471
- Replies: 357,008
- Topics: 52,386
- Snippets: 1,779
- Tutorials: 425
- Total Online: 1,200
- Members: 27
- Guests: 1,173
Who's Online?
|
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.
|
Submitted By: Amadeus
|
|
Rating:

|
|
Views: 42,483 |
Language: C++
|
|
Last Modified: February 25, 2005 |
|
Instructions: Include either the ctype.h OR cctype libraries, as well as the stdlib.h as part of the preprocessor directives. |
Snippet
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
}
Copy & Paste
|
|
|
Reference Sheets
Bye Bye Ads
Free DIC T-Shirt
Related Sites
Monthly Drawing
Partners
Top Contributors
Top 10 Kudos This Month
|