gpt4 book ai didi

c - which function takes no constant parameters similar to system(constant char) in linux

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:11:55 29 4
gpt4 key购买 nike

我想在 c 程序中执行脚本 cmd,所以函数 SYSTEM(CONST CHAR) 可以执行它,但我想使用这个函数和 3 个不同的参数写入一次。谁能帮帮我,有没有那种功能。

最佳答案

如果我猜对了,您想使用类似 system() 的带有多个参数的函数来调用 cmd,如果是,那么您可以执行以下操作

char cmd[SIZE];
snprintf(cmd, <SIZE>, "<cmd> %d %f %c" argument1, argument2, argument3);
system(cmd);

您还可以自定义 snprintf 以满足您的需求和论点。

[编辑] 使用 snprintf 而不是 sprintf [/编辑]

关于c - which function takes no constant parameters similar to system(constant char) in linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4070841/

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