gpt4 book ai didi

c++ - 在 C++ 程序中包含 C 头文件

转载 作者:IT老高 更新时间:2023-10-28 12:37:59 33 4
gpt4 key购买 nike

我有一个 C++ 程序 (.cpp),我希望在其中使用 C 头文件中的一些函数,例如 stdio.h、conio.h、stdlib.h、graphics.h、设备。 h等

我可以在我的 cpp 文件中包含 stdio.h 库:#include <cstdio> .如何包含其他库文件?

如何添加 graphics.h 库?

我使用的是 Microsoft Visual Studio 6.0 企业版和 Turbo C++ 3.0。

最佳答案

对于 C 标准 C 头文件(stdio、stdlib、assert、...)的列表,在前面加上 c 并删除 .h。例如 stdio.h 变成 cstdio。

对于其他标题,请使用

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

关于c++ - 在 C++ 程序中包含 C 头文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3329159/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com