math.h
-> cmath
stdlib.h
-> cstdlib
I understand the difference between the ".h" version and the "c-prefix" version, but what was the reason to choose to use the "c" prefix?
The name qualification is required to disambiguate between std-namespace-qualified versions of the C library headers and same-named C++ library headers. For example: "string.h" contains original C string functions, "cstring" contains std-qualified C string functions, and "string" contains C++ string classes. Without the name qualification, the latter two names would clash.
The headers that end with .h are the original C headers. The ones with the c prefix (and no extension) are the C headers versions incorporated by the C++ Standard (the prefix "reminds" you that). In theory, everything inside them should be inside the std namespace.
EDIT: Okay, we have some people who maybe didn't read the question carefully enough, or made assumptions on what the question meant or how answers were to be interpreted.
I'm answering the below question here:
but what was the reason to choose to use the "c" prefix?
To emphasize that it's originally from the C language, I presume.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With