Jun 7, 2020

#include iostream | #include iomanip | header files | C++ basics | CODING WINDS

#include<iostream>

Hello people, in this blog we are going to discuss the first line of our C/C++ code.


iostream stand for standard ‘input-output stream’.

This is nothing but a header file which is responsible for input and output stream.

Here, ‘input stream’ means when the task is performed in such a way that bytes travels from device(keyboard) to main memory, and ‘output stream’ means when the task is performed in such a way that bytes travel from main memory to your device.

Here “iostream” is a library which contains some predefined functions for example “cout” , “cin” , etc.

And “ #include ” is a word which makes the use of “iostream” possible in our code.

We just not only have “iostream” as a header file for input/output, but also have many other such as “iomanip” , “fstream”

1.    1. iomanip – This stands for ‘input ouput manipulation’. The methods in this file are used to manipulate the streams. This has predefined functions lihe setw, setprecision, etc

2.    2. fstream – This is defined as file stream. This header file is used to handle the data being read from a file as input or data being written into the file as output.

So this was all bookish knowledge, let’s try our hands on some codes showing the use of this ;

EXAMPLE 1 - Code using #include<iostream>


EXAMPLE 2 - Code using #include<iomanip>

 In this code we are going to see how to print '02' or '002' or '0002' in place of some int variable whose value is '2'.


Here the output of this code will be :
   20
00020
--20   

It also have many other pre-defined libraries(e.g. maths.h , cstdio, stdlib, etc ) in C++ language which we have not discussed here, we will discuss in the upcoming blogs.

Do you get why we write "using namespace std;" in every C++ code? If NO then check out our article on this by clicking here.

If you still have any doubt on this topic then do come to us via email "sophomoretechs@gmail.com" or via instagram "@coding.winds".

We also have something on "Dynamic Memory Allocation in C/C++", check it out by clicking here.


No comments:

Post a Comment