How to convert lowercase letters to uppercase in C++?

Convert lowercase letters to uppercase in C++

The function int toupper ( int c ) convert lowercase letter to uppercase. It’s standard build in function in cstring library.

Converts c to its lowercase equivalent if c is an uppercase letter and has a lowercase equivalent. If no such conversion is possible, the value returned is c unchanged.

Example usage of toupper function.

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

 int main ()
 int i; char str[80];

 //char * strcpy ( char * container, const char * input );
 strcpy(str,"my capital letter sentence.");

 for(i=0; str[i]; i++)
 str[i] = toupper(str[i]);
 cout << str<<endl;

 return 0;
}//end of main

 Program Output


You must be logged in to post a comment.

Proudly powered by WordPress   Premium Style Theme by
%d bloggers like this: