Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. what is the difference ...?

what is the difference ...?

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yaaqub
    wrote on last edited by
    #1

    Hi, cout << "*"<< endl; and cout << '* '<

    R P 2 Replies Last reply
    0
    • Y yaaqub

      Hi, cout << "*"<< endl; and cout << '* '<

      R Offline
      R Offline
      RChin
      wrote on last edited by
      #2

      Well one's outputting a string and the other is outputting a character. so you could do this: std::cout<<"This string"< but this will surely give you problems: `std::cout<<'this is invalid'< * * * **I Dream of Absolute Zero**`

      1 Reply Last reply
      0
      • Y yaaqub

        Hi, cout << "*"<< endl; and cout << '* '<

        P Offline
        P Offline
        PJ Arends
        wrote on last edited by
        #3

        The first one outputs a asterix because the double quotes denotes a char array, the second one is a little trickier because you are using a single quote to wrap two bytes. That means that the operator << is outputting a short (two bytes) instead of a char (one byte). Try this

        cout << "asdf" << endl;
        cout << 'asdf' << endl;

        and you get the same type of result.


        You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it! -- modified at 17:48 Thursday 23rd March, 2006

        N 1 Reply Last reply
        0
        • P PJ Arends

          The first one outputs a asterix because the double quotes denotes a char array, the second one is a little trickier because you are using a single quote to wrap two bytes. That means that the operator << is outputting a short (two bytes) instead of a char (one byte). Try this

          cout << "asdf" << endl;
          cout << 'asdf' << endl;

          and you get the same type of result.


          You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it! -- modified at 17:48 Thursday 23rd March, 2006

          N Offline
          N Offline
          normanS
          wrote on last edited by
          #4

          Is 'asdf' valid? I thought single quotes only applied to single characters?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups