I am having trouble with the toupper function.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gdarian216
    New Member
    • Oct 2006
    • 57

    I am having trouble with the toupper function.

    I am tring to write a program that takes a input char and if it is lower case changes it to capital, then outputs the value. If it is already capital it just outputs the value. this is what i was thinking but it isnt working.
    #include<iostre am>
    #include<cctype >
    using namespace std;

    int main()
    {
    char a;
    cin >> a
    while (cin.get(chr))
    {
    int toupper(a);
    static_cast<cha r>(int) toupper(a));
    cout << a;

    }}
    i guess my real problem is i really dont understand how the get function works with the int toupper.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    what is wrong with

    Code:
    int main()
    {
        char a;
    
        cin >> a
        a = (char)toupper(a);
        cout << a;
    
        return 0;
    }
    ?

    Comment

    • gdarian216
      New Member
      • Oct 2006
      • 57

      #3
      Originally posted by Banfa
      what is wrong with

      Code:
      int main()
      {
          char a;
      
          cin >> a
          a = (char)toupper(a);
          cout << a;
      
          return 0;
      }
      ?
      thanks a lot i think i was doin 2 much with it.

      Comment

      Working...