Referencing functions in c header files in c ++

Sometimes in C ++, there are two ways to refer to the function in the C header file; take the <stdlib.h> in the C language as an example

In c, we want to use the function in <stdlib.h>, the form is: #include <stdlib.h>

In C ++, we want to use the functions in <stdlib.h>. The first form is: #include <cstdlib>, the suffix .h is removed, and the prefix c.

The second form is: #include <stdlib.h>, this form is the same as the form of c, but in order to distinguish between C ++ and C, the first form is generally used in C ++.

In addition, I have to talk about it again. Although the functions in the two types of header files #include <cstdlib> and #include <stdlib.h> are the same and the method of use is the same, but one thing to know is

These header files in c ++ that start with c such as cstdio, cstdlib, ctime, etc., are all standard c ++ header files in c that repackage the header file, which encapsulates the functions in the c header file into the std namespace . E.g,

cstdlib implements all the functions in stdlib.h, but it is written in the manner of c ++.

Guess you like

Origin www.cnblogs.com/buanxu/p/12748049.html