Converts the input characters to uppercase if they aren't already. - C++ Data Type

C++ examples for Data Type:char

Description

Converts the input characters to uppercase if they aren't already.

Demo Code

#include <iostream>
using namespace std;
int main()//from ww w  .  j  a  v a2 s . c  om
{
   char first, middle, last;   // Will hold user's initials
   int bitmask=223;                   // 11011111 in binary
   cout << "What is your first initial? ";
   cin >> first;
   cout << "What is your middle initial? ";
   cin >> middle;
   cout << "What is your last initial? ";
   cin >> last;
   // Ensure that initials are in uppercase.
   first = first & bitmask;            // Turn off bit 5 if
   middle = middle & bitmask;          // it is not already
   last = last & bitmask;              // turned off.
   cout << "Your initials are " << first << " " << middle << " " << last;
   return 0;
}

Result


Related Tutorials