Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is C++ still using stdio.h?

this is probably a dumb question, but I couldnt find the answer I was looking for. Also, I was unsure if this was a C++ question or a VS2010 question, but the answer I'm looking for is that of a technical POV, so I ended up here.

When you start a new Console Application project in VS2010, it automatically includes stdafx.h, which in turn includes stdio.h. The answers I found regarding stdio.h vs. iostream was more or less:

stdio.h was used in C and iostream is used in C++

I dont know if this is right or wrong, but...

My question is: Why is stdio.h still automatically included in C++ projects? Wouldnt iostream be sufficient?

like image 328
Roger Avatar asked Jan 16 '11 16:01

Roger


2 Answers

IO streams in older C++ implementations were pretty slow, leading programmers to keep using stdio.h. Apparently, that got included in stdafx.h in the past and cannot be removed from that header anymore as removing it would break existing code.

like image 143
Fred Foo Avatar answered Oct 17 '22 20:10

Fred Foo


Usually projects are created using Create Empty Project, so that you can customize your includes and precompiled headers yourself.

I have no idea why does this "default" include happens, but it's a good thing to setup your project from scratch as I've described before.

like image 31
Yippie-Ki-Yay Avatar answered Oct 17 '22 21:10

Yippie-Ki-Yay