Including C headers inside a C++ program

后端 未结 5 896
情歌与酒
情歌与酒 2020-11-30 03:19

I have a C++ program (.cpp) inside which I wish to use some of the functions which are present inside the C header files such as stdio.h, conio.h, stdlib.h, graphics.h, devi

5条回答
  •  一整个雨季
    2020-11-30 03:51

    For a list of C standard C headers (stdio, stdlib, assert, ...), prepend a c and remove the .h. For example stdio.h becomes cstdio.

    For other headers, use

    extern "C"
    {
      #include "other_header.h"
    }
    

提交回复
热议问题