Lower Case
2002-08-30 13:04:40
Category: cpp:strings
Description: Conver upper case charecters in a string to lower case.
Author: detour
Viewed: 3385
Rating: (10 votes)


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