Thread: toupper() function

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    224

    Cool 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

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    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.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    224

    Thumbs up

    thank you very much!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM