Difference between cout and puts() in C++ with Examples Last Updated : 08 Jul, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. Differences are: S.NOcoutputs()1 It is a predefine object of ostream class.puts is a predefine function (library function).2cout is an object it uses overloaded insertion (<<) operator function to print data.puts is complete function, it does not use concept of overloading.3cout can print number and string both.puts can only print string.4to use cout we need to include iostream.h header file.To use puts we need to include stdio.h header file. Program 1: C++ // C++ program use of puts #include <iostream> #include <stdio.h> using namespace std; // main code int main() { puts("Geeksforgeeks"); fflush(stdout); return 0; } Output: Geeksforgeeks Program 2: Below program do not require fflush to flush the output buffer, because cout has it inbuilt. C++ // C++ program use of cout #include <iostream> using namespace std; // main code int main() { cout << "Geeksforgeeks" << endl; return 0; } Output: Geeksforgeeks Comment More infoAdvertise with us Next Article What is the Difference Between C++ String == and compare()? S shivanisinghss2110 Follow Improve Article Tags : C++ Programs Difference Between C++ CPP-Functions Practice Tags : CPP Similar Reads What is the Difference Between C++ String == and compare()? In C++ == and compare() both are used to compare strings and find if the given strings are equal or not but they differ in working. In this article, we will learn the key differences between == and compare() of string in C++. "==" Operator in C++The == operator in C++ is used to compare two strings 3 min read Difference Between string and char[] Types in C++ In C++, we can store the sequence of characters i.e. string in two ways: either as a std::string object or char array. In this article, we will discuss some major differences between string and char[] in C++.Character Array Type StringsA character array is simply an array in C++ that contains charac 2 min read Binary literals in C++14 with Examples In this article, we will discuss Binary literals in C++14. While writing programs which involve mathematical evaluations or various types of number, we usually like to specify each digit type with specific prefix i.e., For Hexadecimal number use the prefix '0x' and for Octal number use the prefix '0 2 min read Difference between std::set vs std::vector in C++ STL Vectors: Vectors are containers similar to dynamic arrays, with the ability to resize when a new element is inserted or deleted from it. It is a template of Standard Template Library or STL, which provides more flexibility to the program. Elements of vectors are placed in contiguous storage and are 2 min read Life cycle of Objects in C++ with Example In Object Oriented Programming, Objects are the instances of a class which has its own state(variables) and behavior(methods). Every class has two special methods related with creation and destruction of object of a class- constructors and destructors. C++ Object Life Cycle: There are various steps 6 min read Different Ways to Copy a Vector in C++ Copying a vector is the process of creating a new vector that contains same elements as original vector. In this article, we will learn different ways to copy a vector in C++.The most efficient and easiest method to copy a vector in C++ is by using assignment operator (=). Letâs take a look at an ex 4 min read Like