gpt4 book ai didi

C 系统函数在其他字符串之前获取

转载 作者:行者123 更新时间:2023-11-30 21:20:37 25 4
gpt4 key购买 nike

我正在尝试编写一个简单的 C 程序来打印 C 编译器版本。所以我写道:

#include <stdio.h>
int main() {
printf("you have %d", system("gcc --version");
}

输出:

gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

you have compiler 0

有什么想法吗?

最佳答案

system 执行 shell 命令并返回命令的状态。在您的情况下,值为 0 意味着命令已成功运行。

关于C 系统函数在其他字符串之前获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36233842/

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