printf vs cout

This is a discussion on printf vs cout within the C++ Programming forums, part of the General Programming Boards category; Im new to C/C++ and I vaguely understand the differences between the printf and cout. I have used cout in ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    37

    printf vs cout

    Im new to C/C++ and I vaguely understand the differences between the printf and cout. I have used cout in a few small things I wrote but I see a lot of people using printf too. So, should I stick with cout until I get a better grasp of how things work or is printf a necessity for even beginners?

  2. #2
    Akilla
    Guest

    cout vs printf

    printf is old style, but it is not inferior when compared to cout.

    however, the speciality of cout is that you dont need to put %d, %c stuff while printing variables, hence the syntax is easier


    www.akilla.tk

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    in reality, cout is an object that encapsulates printf. it overloads operator << for a bunch of types so that it can cat. to the buffer. the buffer is then flushed when the endl is given and the printf is actually called. so the only difference really is that you're dealing with an object that does a lot of your dirty work.

  4. #4
    Registered User
    Join Date
    Jun 2002
    Posts
    106
    printf comes from c ,c++ uses cout but becouse c++ accepts c type writing people can use printf instead of cout but the new style is cout .

  5. #5
    Registered User whistlenm1's Avatar
    Join Date
    Jan 2002
    Posts
    124
    For now I mainly still use printf (my Preference), although as I have just started learning templates I believe I will have problems with printf and templates, i.e., how do you use printf to output a type that can be of any type?
    Man's mind once streched by a new idea, never regains its original dimensions
    - Oliver Wendell Holmes

    In other words, if you teach your cat to bark (output) and eat dog food (input) that doesn't make him a dog. It would have to chase cars, chew bones, and have puppies before I'd call it Rover ;-)
    - WaltP

  6. #6
    Registered User
    Join Date
    Jul 2002
    Posts
    37

    performance

    ok.. does anyone know if one performs better than another? It seems printf would be the better choice but I have nothing to base this on...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. making it portable.....?
    By ShadeS_07 in forum C Programming
    Replies: 11
    Last Post: 12-24-2008, 09:38 AM
  3. Need Help with a Bowling Score Program
    By oobootsy1 in forum C++ Programming
    Replies: 6
    Last Post: 11-01-2005, 10:04 AM
  4. Whats Wrong Whith This!?
    By SmokingMonkey in forum C++ Programming
    Replies: 8
    Last Post: 06-01-2003, 10:42 PM
  5. (printf VS cout) and (including libraries)
    By \cFallen in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2003, 09:47 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21