Skip to content
How bits/stdc++.h works

How the bits/stdc++ .h works in C++

I often wonder, How does #include < bits/stdc++.h> work?. I’ve seen this while solving competitive problems and referring to various solutions and I wanted to know what’s happening in the background.

Here’s what I found

  1. It is a precompiled header file that contains every standard library
  2. Once, we use this there is no need to use any other header files

As said in point 1, this includes all library files including STL and everything

When and How to use this?

Now, instead of searching or memorizing the names of various header files, we can save a lot of time by just adding this one header in the beginning.

But, wait. Including every other header file and all the libraries which we are never gonna use might waste a lot of time and compile time.

So, if you’re looking to save some time and make your code more efficient, you probably don’t wanna use this.

Important: The < bits.stdc++ .h> is not a part of GNU C++ library. It might not work with all compilers or XCode

<bits/stdc++ .h> in Competitions

Often in the competitive contest and test platforms, this is put to use to save some time and concentrate on the logic and solving the problem at first hand.

Conclusion

This post is a part of my #30DaysChallenge to write a blog post every day on what I learn daily. Happy Coding ~ Abhiram Reddy