/* Lecture code 7.1
 *
 * ConvertToUpperCase and ConvertToLowerCase.  Note the :: madness here
 * is for g++ / XCode but is not necessary in MSVC++.
 */

#include <string>
#include <cctype>    // for toupper, tolower
#include <iostream>
#include <algorithm> // for transform
using namespace std;
 
string ConvertToUpperCase(string input)
{
	/* Apply toupper to each element and store it back in itself.  Note that the icky
	 * :: is not needed in Visual Studio.
	 */
	transform(input.begin(), input.end(), input.begin(), ::toupper);
	return input;
}
 
string ConvertToLowerCase(string input)
{
	/* Apply tolower to each element and store it back in itself. */
	transform(input.begin(), input.end(), input.begin(), ::tolower);
	return input;
}

int main()
{
	cout << ConvertToUpperCase("this is upper case!") << endl;
	cout << ConvertToLowerCase("THIS IS LOWER CASE!") << endl;
	return 0;
}