Header file: cctype
// Converting lowercase letters to uppercase letters
#include <iostream>
#include <cctype> // For the use of toupper Function.
using namespace std;
int main()
{
char a = 'a';
char b = toupper(a);
cout << b << endl;
return 0;
}
//====================================
Better way:
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
char a = 'a';
cout << static_cast<char>( toupper(a) ) << endl;
return 0;
}
//---------------------------------------------------
//You will be thinking now, why we used static_cast<char> ?
//If we would have done as follows, what was wrong?
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
char a = 'a';
cout << toupper(a) << endl;
return 0;
}
// Converting lowercase letters to uppercase letters
#include <iostream>
#include <cctype> // For the use of toupper Function.
using namespace std;
int main()
{
char a = 'a';
char b = toupper(a);
cout << b << endl;
return 0;
}
//====================================
Better way:
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
char a = 'a';
cout << static_cast<char>( toupper(a) ) << endl;
return 0;
}
//---------------------------------------------------
//You will be thinking now, why we used static_cast<char> ?
//If we would have done as follows, what was wrong?
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
char a = 'a';
cout << toupper(a) << endl;
return 0;
}