Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 3
    For console I/O es macht nichts (it doesn't matter). In the big picture, printf is not compatible with C++ streams. C++ streams allow you to easily convert your console output to a file. (Although you can do similar with fprintf). Commented Jan 7, 2010 at 1:00
  • 1
    what about using sprintf + cout then? Commented Jan 7, 2010 at 2:32
  • 15
    Mote that your two lines are not strictly equivalent. endl also flushes the stream, as if you had written printf("(%d,%d)\n", x, y); fflush(stdout); This can add a big performance hit if executed repeatedly in a loop. To get a real equivalent of your printf statement in C++ you should write cout << "(" << x << "," << y << ")\n"; Commented Jan 7, 2010 at 8:49
  • 2
    @bobobobo, A typo for "Note". Commented Sep 12, 2012 at 1:47
  • Possible duplicate of 'printf' vs. 'cout' in C++ Commented Jun 7, 2018 at 13:23