r/cpp • • Mar 19 '20

Why so many students are using '#include<bits/stdc++.h>' instead of '#include<iostream>'?

I am hiring for my company. And the codes submitted for a test problem has '#include<bits/stdc++.h>' at the beginning. The MacOS default compiler complains

main.cpp:1:9: fatal error: 'bits/stdc++.h' file not found

#include<bits/stdc++.h>

^~~~~~~~~~~~~~~

1 error generated.

Why people are using '#include<bits/stdc++.h>'?

225 Upvotes

163 comments sorted by

View all comments

185

u/[deleted] Mar 19 '20

Because they are mostly folks who are coming in via competitive programming backgrounds and/or most of the C++ stuff they saw comes from websites like geeksforgeeks, where other competitive programmers write algorithm tutorials in C++ using patterns like this.

I have said it once and I have said it before, if a candidate's exposure to C++ is only through competitive programming or leetcode, then their C++ experience is not to be taken seriously. They may know some things about the STL, their concepts like OO, templates, move semantics, memory management, concurrency, build systems, testing i.e stuff that actually matters in a production C++ environment, are seriously lacking or non-existent.

I took a guess that you're from India, and well, looks like you are, this is very prevalent there.

101

u/mort96 Mar 19 '20

I noticed Geeksforgeeks recommending including <bits/stdc++.h> too. It's actually really bad that the biggest websites with the best SEO for introductory C++ google searches are teaching such blatantly incorrect practices.

69

u/[deleted] Mar 19 '20

don't even get me started on using namespace std; plastered everywhere.

79

u/redditsoaddicting Mar 19 '20
#include <bits/stdc++.h>
using namespace std;

Wish I could say it's a joke.

4

u/AlarmDozer Mar 20 '20

And here I am exclusively using

std::cout “hello, puffin!” std::endl;

/sigh

6

u/redditsoaddicting Mar 20 '20

Did I mention this is in a header?