Saturday 2 September 2017

What is bits/stdc++.h in C++?(master file in C++)

<bits/stdc++.h> is a master file in c++. It is basically a header file which includes every standard library file. you need this file when you don't know which standard file is included in the program. It saves our time and solves the confusion. Let take an example if you want to find square root of a number, you have to include <math.h> file but if you use  <bits/stdc++.h> you don't need any other file.

#include<bits/stdc++.h>
using namespace std;
int main()
{
   float a;
   cout<<"Enter the number:";
   cin>>a;
   cout<<"Square root of the number is:"<<sqrt(a)<<endl;
   return 0;
}

output:-

Enter the number:3
Square root of the number is:1.73205

NOTE: <bits/stdc++.h> is use instead of <iostream> in C++.

ADVANTAGES:-


  1. In the competitive contest, using this file is a good idea, when you want to reduce the time wasted in doing chores, especially when your rank is time sensitive.
  2. It reduces typing in the program and solves the confusion.
  3. you don't have to remember all the  STL of GNU C++ for every function you use.
DISADVANTAGES:-


  1. It is not a standard header file of GNU C++ library. If you use other compilers it might fail. Like there is no such file in MICROSOFT VISUAL STUDIO.
  2. Using it would increase lots of unnecessary stuff and increases compile time.
  3. This header file is not a standard header file of C++ so, non-portable and should be avoided.

0 comments:

Post a Comment