Try this. Note that it doesn't convert the string as mentioned by Paul in post #11. It just outputs the string in uppercase as per your original upr function.

Code:
void upr(const string& str)
{
	for (const char* ptr = str.c_str(); *ptr; ++ptr)
		cout << (char)toupper(*ptr);

	cout << endl;
}