stdio.h not standard in C++?

vladutcornel picture vladutcornel · Sep 29, 2011 · Viewed 13.6k times · Source

I know most compilers allow both:

#include <stdio.h>

and

#include <cstdio>

But someone argued that <stdio.h> is not actually C++ standard. Is that true?

Answer

Lightness Races in Orbit picture Lightness Races in Orbit · Sep 29, 2011

stdio.h is standard, but deprecated. Always prefer cstdio in C++.

[n3290: C.3.1/1]: For compatibility with the Standard C library, the C++ standard library provides the 18 C headers (D.5), but their use is deprecated in C++.

[n3290: D.5/3]: [ Example: The header <cstdlib> assuredly provides its declarations and definitions within the namespace std. It may also provide these names within the global namespace. The header <stdlib.h> assuredly provides the same declarations and definitions within the global namespace, much as in the C Standard. It may also provide these names within the namespace std. —end example ]