Standard Output Stream(cout): The C++ cout statement is the instance of the ostream class. It is used to display output on the standard output device which is usually the display screen. The data needed to be displayed on the screen is inserted in the standard output stream (cout) using the insertion operator(<<). For more details prefer to this article.
puts(): It can be used for printing a string. It is generally less expensive, and if the string has formatting characters like ‘%’, then printf() would give unexpected results. If string str is a user input string, then use of printf() might cause security issues. For more details prefer to this article.
|1||It is a predefine object of ostream class.||puts is a predefine function (library function).|
|2||cout is an object it uses overloaded insertion (<<) operator function to print data.||puts is complete function, it does not use concept of overloading.|
|3||cout can print number and string both.||puts can only print string.|
|4||to use cout we need to include iostream.h header file.||To use puts we need to include stdio.h header file.|
Program 2: Below program do not require fflush to flush the output buffer, because cout has it inbuilt.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between cout and std::cout in C++
- Cin-Cout vs Scanf-Printf
- Difference between an Integer and int in Java with Examples
- Difference between Iterators and Pointers in C/C++ with Examples
- Difference between Argument and Parameter in C/C++ with Examples
- Difference between Iterator and Enumeration in Java with Examples
- Difference between Abstraction and Encapsulation in Java with Examples
- Difference between Java and Kotlin in Android with Examples
- Difference between NULL pointer, Null character ('\0') and '0' in C with Examples
- Difference between super and super() in Java with Examples
- Difference between DVD-R and DVD-RW
- Difference between AIX and IBM i
- Difference between AIX and HP-UX
- Difference Between Gi-Fi and Li-Fi
- Difference between CRT and LCD
- What is the difference between GUI and CUI?
- Difference between AIX and QNX
- Difference between CPU and GPU
- Difference between AIX and OS/2
- Difference between AIX and iOS
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.