Home
Aptitude
Categories


Home » C++ programming language

<bits/stdc++.h> as header file in C++



In this article, we are going to see how useful <bits/stdc++.h> is as a header file for competitive programing?
Submitted by Radib Kar, on December 03, 2018

<bits/stdc++.h> header file

It's the header file that includes every header files, i.e., links every header file to our program.

The following code chunk is enough to include every header file needed to be linked in the program.

    #include <bits/stdc++.h>
    Using namespace std;  

Like you don’t need to put your time on writing & finding each header file to be mentioned, instead, just add this piece of code chunk.

It’s true that including <bits/stdc++.h>, makes the program size larger and increase the complexity time. Also it’s not part of standard library and can only be used in gcc compiler. Other compilers like MSVC(Microsoft Visual C++) don’t have this header.

Though <bits/stdc++.h> has such pitfalls, we are not at all bothered by this, since our only focus is on competitive coding context, where we are only concerned about run time complexity, not compile time. Also gcc is used everywhere. Thus using <bits/stdc++.h> is a very efficient coding style for solving interview coding problems.

One more thing can be very tricky is when we have functional problems to solve. There may be case we have a functional problem, where we need to write the function only & rest of the code is already given (can’t be modified). In such case, we may need to use STL, but so such header file is included in the given code for STL. In such case, it might seem that, we can’t use STL here & we need to take any other way, which is not at all efficient. If you think so, wait a minute!!!

You can add #include <bits/stdc++.h> anywhere in the code, since it’s an ANCI MACRO. That’s why just write #include <bits/stdc++.h> before where you start using STL. (Before the function). That’s all.

For example check all my codes (Radib Kar's articles), as I use it everywhere!!






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.