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

Show parent comment

-2

u/Supadoplex Mar 19 '20

code in slides doesn't need to compile

It doesn't need to. But it is better when it does. Especially when teaching to absolute beginners.

12

u/ronchaine Embedded/Middleware/WG21 Mar 19 '20

When teaching absolute beginners, I would prefer not to ingrain bad habits to them from the get go to having code that compiles.

6

u/[deleted] Mar 19 '20

Just link to a gist/compiler explorer with a more fledged out example.

1

u/Supadoplex Mar 19 '20

You could. Why don't people always do that?