gpt4 book ai didi

c程序将ipconfig保存在文件中

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

我有以下代码,是否可以将 ipconfig 结果存储在文件中。请帮我解决这个问题

#include<stdlib.h>

int main()
{
system("C:\\Windows\\System32\\ipconfig");
return 0;
}

ipconfig 结果将保存到名为 ip.txt 的文本文件中 请帮我解决这个问题。提前致谢

最佳答案

试试这个:

system("C:\\Windows\\System32\\ipconfig > myfile.txt");

编辑:

如果你想将 stdoutstderr 都放在文件中(感谢 @user3629249 的评论):

system("C:\\Windows\\System32\\ipconfig 2>&1 myfile.txt");

编辑 2:

如果您想了解更多关于重定向的信息,请查看微软的redirection operators tutorial .

关于c程序将ipconfig保存在文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34509901/

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