outputing hexidecimal using cout

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • daniel aviad galron

    outputing hexidecimal using cout

    Greetings. I need to output a hexadecimal number using cout. I've done
    this as shown below:
    cout << hex << stuff;
    But it outputs the letters in lowercase. Is it possible to output
    a,b,c,d,e, and f in upper case instead of lower case?

    Thanks

    -D

  • Josh Sebastian

    #2
    Re: outputing hexidecimal using cout

    On Sun, 12 Oct 2003 20:45:45 -0400, daniel aviad galron wrote:
    [color=blue]
    > Greetings. I need to output a hexadecimal number using cout. I've done
    > this as shown below:
    > cout << hex << stuff;
    > But it outputs the letters in lowercase. Is it possible to output
    > a,b,c,d,e, and f in upper case instead of lower case?[/color]

    Did you try

    cout << hex << uppercase << stuff;

    ?

    Comment

    • Mike Wahler

      #3
      Re: outputing hexidecimal using cout


      "daniel aviad galron" <galron@cis.ohi o-state.edu> wrote in message
      news:3F89F5B9.4 070002@cis.ohio-state.edu...[color=blue]
      > Greetings. I need to output a hexadecimal number using cout. I've done
      > this as shown below:
      > cout << hex << stuff;
      > But it outputs the letters in lowercase. Is it possible to output
      > a,b,c,d,e, and f in upper case instead of lower case?[/color]

      Yes. Your needs have been anticipated and provided
      via another handy-dandy stream manipulator:

      #include <iomanip>
      #include <iostream>

      int main()
      {
      std::cout << std::hex << std::uppercase << 0x3d << '\n';
      return 0;
      }

      -Mike


      Comment

      • Mike Wahler

        #4
        Re: (corr) outputing hexidecimal using cout


        "Mike Wahler" <mkwahler@mkwah ler.net> wrote in message
        news:ienib.8890 $dn6.3684@newsr ead4.news.pas.e arthlink.net...[color=blue]
        >
        > "daniel aviad galron" <galron@cis.ohi o-state.edu> wrote in message
        > news:3F89F5B9.4 070002@cis.ohio-state.edu...[color=green]
        > > Greetings. I need to output a hexadecimal number using cout. I've done
        > > this as shown below:
        > > cout << hex << stuff;
        > > But it outputs the letters in lowercase. Is it possible to output
        > > a,b,c,d,e, and f in upper case instead of lower case?[/color]
        >
        > Yes. Your needs have been anticipated and provided
        > via another handy-dandy stream manipulator:
        >
        > #include <iomanip>[/color]

        Should be:

        #include <ios>

        -Mike


        Comment

        Working...