gpt4 book ai didi

c++ - system() 函数属于 C 还是 C++?

转载 作者:太空狗 更新时间:2023-10-29 23:25:26 29 4
gpt4 key购买 nike

#include <stdio.h>
#include <stdlib.h>
void main ()
{
system("dir");
}

我读过许多 C++ 书籍,其中 system() 用于执行命令行程序。但是当我在 C 中尝试相同的命令时,它运行得很好。所以我的问题是它是标准的 C 还是 C++ 函数?请放宽点,因为我是 C 编程的新手。

最佳答案

由于系统函数是在 stdlib.h 中声明的,因此可以将其视为 C 函数。但在 C++ 中,stdlib.h 被合并到 std 命名空间中,并以这种形式位于 cstdlib include 中。所以正确答案是“两者”。

关于c++ - system() 函数属于 C 还是 C++?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26404835/

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