strlwr() and strupr(): Converting a string to lowercase or uppercase in C++ Options

davegate 133 - 876
@2015-12-17 18:04:52

In C++, function strlwr() is used to convert a string to lowercase and function strupr() is used to convert string to uppercase.

The following code demonstrates how to use these two functions:

#include <string>
#include <iostream>
using namespace std;

int main(void)

    char name[80]; /* declare an array of characters 0 – 79 */
    memset(name,0, sizeof(name));

    cout << "Enter in a name in lowercase:";
    cin >> name;
    cout << "The name in uppercase is: " << name << endl;
    cout << "The name in lowercase is: " << name << endl;

    return 0;
Users browsing this topic