-
toupper() function
Hi,
I am using toupper() on user input and then I want to display the answer after its been touppered.
But the program shows me the ascii value for the letter rather than the character. Even though I am using toupper() on a char variable.
Code:
#include <iostream>
//#include <ctype.h> // Makes the toupper function available to the compiler
using namespace std;
void main ()
{
char userInput = ' ';
cout << "Please enter a character: ";
cin >> userInput;
cout << "The letter you entered was: " << toupper(userInput) << endl;
}
2. On a different note. I am using VS 2005 express. Why is it that for some header files (eg, iostream) when I put the extension, the '.h' in with the name the compiler gives an error. And for other header files, if I dont put the '.h' I get an error. Not very consistent. IS the problem me? anyone tell me why this is?
Thanks for looking, your advice and help are appreciated
-
All C++ standard headers don't have an .h.
All C standard headers do have an .h.
Most headers from other libraries have an .h.
So for this program you would need <iostream> and <cctype>. (You could use the C standard header <ctype.h> instead, but that would be silly in a C++ program.)
toupper returns an int (it takes an int, too) which can be EOF.
-