C++: printf Vs cout

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ying Yang

    C++: printf Vs cout

    Hi,

    Whats the difference between printf and cout? They both seem to do the same
    thing.


    Regards
    dsfg


  • Unforgiven

    #2
    Re: printf Vs cout

    Ying Yang wrote:[color=blue]
    > Hi,
    >
    > Whats the difference between printf and cout? They both seem to do
    > the same thing.[/color]

    Please check if this answers your question:


    --
    Unforgiven

    "Most people make generalisations "
    Freek de Jonge

    Comment

    • Anthony

      #3
      Re: printf Vs cout

      Hi,
      There is a whole book written about streams (cout).
      Think you'll find your answer there.


      If that's not enough, here is a link to a very good c++ book (also available
      online)

      The second edition of this book contains a chapter about streams.
      You will find the printf vs cout here.

      Greetingz
      Anthony


      "Ying Yang" <YingYang@hotma il.com> schreef in bericht
      news:3f717ef6_1 @news.iprimus.c om.au...[color=blue]
      > Hi,
      >
      > Whats the difference between printf and cout? They both seem to do the[/color]
      same[color=blue]
      > thing.
      >
      >
      > Regards
      > dsfg
      >
      >[/color]


      Comment

      • tom_usenet

        #4
        Re: C++: printf Vs cout

        On Wed, 24 Sep 2003 20:54:46 +0930, "Ying Yang" <YingYang@hotma il.com>
        wrote:
        [color=blue]
        >Hi,
        >
        >Whats the difference between printf and cout? They both seem to do the same
        >thing.[/color]

        printf << "Hello"; //error
        cout("%s", "Hello"); //error

        In other words, they have completely different syntax. C++ has both, C
        only has printf.

        In high level terms, the main differences are type safety (cstdio
        doesn't have it), performance (most iostreams implementations are
        slower than the cstdio ones) and extensibility (iostreams allows
        custom output targets and seamless output of user defined types).

        Tom

        Comment

        • Kevin Goodsell

          #5
          Re: printf Vs cout

          Anthony wrote:
          [color=blue]
          > Hi,[/color]

          Please don't top-post. Read section 5 of the FAQ for posting guidelines.



          -Kevin
          --
          My email address is valid, but changes periodically.
          To contact me please use the address from a recent posting.

          Comment

          Working...