out-6ren">
gpt4 book ai didi

c - C 中的 System() 函数显示有错误的输出

转载 作者:太空宇宙 更新时间:2023-11-04 06:42:52 26 4
gpt4 key购买 nike

我正在使用 C 中的 system() 函数来运行系统命令。在使用 system() 时,我使用的命令是:

system("C:\splint-3.1.2\bin\splint first.c>output.txt");

但是,此输出未正确发送到 txt 文件。更具体地说,会创建 txt 文件,但不会将输出附加到文件中。

从 CMD 运行相同的命令时,输出会正确发送到 txt 文件。

知道出了什么问题吗?

最佳答案

转义反斜杠,以便编译器正确解释它们:

system("C:\\splint-3.1.2\\bin\\splint first.c>output.txt");

关于c - C 中的 System() 函数显示有错误的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5498809/

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