Upper Case
2002-01-31 20:06:48
Category: cpp:strings
Description: Convert lower case characters in a string to upper case.
Author: detour
Viewed: 3737
Rating: (14 votes)


 
			
/* upcase.cpp written by detour@metalshell.com
 * 
 * Function to convert lower case letters to upper case.
 *
 * http://www.metalshell.com
 *
 */
 
#include <iostream>
#include <cctype>
 
using namespace std;
 
void do_upcase(char *);
 
int main() {
    char text[50];
 
    cout << "Enter a string: ";
    cin >> text;
 
    do_upcase(text);
 
    cout << text << endl;
 
    return 0;
}
 
void do_upcase(char *lc) {
    for(;*lc;lc++)
        *lc = (unsigned char)toupper((unsigned char)*lc);
}