How to convert a character to uppercase in C++

2 Answers

0 votes
#include <iostream>
#include <algorithm>
#include <string> 

using namespace std;

int main()
{
	string ch = "g";

	transform(ch.begin(), ch.end(), ch.begin(), toupper);

	cout << ch << endl;

	return 0;
}


/*
run:

G

*/

 



answered Jan 10, 2017 by avibootz
0 votes
#include <iostream>
#include <algorithm>
#include <string> 

using namespace std;

int main()
{
	char ch = 'q';

	ch = toupper(ch);

	cout << ch << endl;

	cout << (char)toupper('g') << endl;

	return 0;
}


/*
run:

Q
G

*/

 



answered Jan 10, 2017 by avibootz

Related questions

2 answers 272 views
2 answers 175 views
1 answer 203 views
1 answer 214 views
2 answers 176 views
176 views asked Jan 10, 2017 by avibootz
...