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 261 views
2 answers 171 views
1 answer 200 views
1 answer 212 views
2 answers 174 views
174 views asked Jan 10, 2017 by avibootz
...