'printf' vs. 'cout' in C++

后端 未结 16 1540
梦如初夏
梦如初夏 2020-11-22 07:04

What is the difference between printf() and cout in C++?

16条回答
  •  囚心锁ツ
    2020-11-22 07:29

    More differences: "printf" returns an integer value (equal to the number of characters printed) and "cout" does not return anything

    And.

    cout << "y = " << 7; is not atomic.

    printf("%s = %d", "y", 7); is atomic.

    cout performs typechecking, printf doesn't.

    There's no iostream equivalent of "% d"

提交回复
热议问题