C++ originated as a subset of C, and it is still true that most C code will work in a C++ program.
The opposite is not true. There are many features that C++ has, that a C compiler will not understand. Trying to use a C++ standard library header is almost certain to cause compilation to fail.
As far as the standard library is concerned, it is normal for header files from the C standard library to end in
.h
. It is normal for header files from the C++ standard library to not have that extension. So, for example:
1 2 3
|
#include <stdio.h> // This is from the C standard library
#include <iostream> // This is from the C++ standard library
#include <cstdio> // This is from the C++ library, and implements in C++ the things that are implemented in stdio.h in C
| |
So that can give you a big hint.
However, third-party libraries tend not to use that convention. Sometimes
.hpp
is used for C++ headers, so that can give you a big clue, but often
.h
is used for C++ as well as C, so you can't use that reliably.
The only sure way to know, is to put in the work to:
1) Learn the language you're programming in
properly.
2) Read the documentation. You're on the internet, so this is all just a search away.