使用system()附加到文件 [英] Appending to a File using system()
问题描述
我一直在使用system()命令将
程序的结果写入文件。这可以通过以下方式实现:
运行netstat例如:
system(" netstat example.txt");
当我再次运行命令时,它会使用
新结果完全重写文本文件。我想要做的是再次运行命令并将
结果附加到文本文件而不是完全重写
文本文件。我已经尝试了几个混合命令使用< fstreambut
什么都没有用。感谢您的帮助。
I have been using the system() command to write the results of a
program to a file. This is being accomplished by the following when
running netstat for example:
system("netstat example.txt");
When I run the command again, it completely rewrites the text file with
new results. What I would like to do is run the command again and have
the results append to the text file instead of completely rewriting the
text file. I have tried several hybrid commands using <fstreambut
nothing has worked yet. Thanks for any help.
推荐答案
Reggie写道:
Reggie wrote:
I一直在使用system()命令将
程序的结果写入文件。这可以通过以下方式实现:
运行netstat例如:
system(" netstat example.txt");
当我再次运行命令时,它会使用
新结果完全重写文本文件。我想要做的是再次运行命令并将
结果附加到文本文件而不是完全重写
文本文件。我已经尝试了几个混合命令使用< fstreambut
什么都没有用。谢谢你的帮助。
I have been using the system() command to write the results of a
program to a file. This is being accomplished by the following when
running netstat for example:
system("netstat example.txt");
When I run the command again, it completely rewrites the text file with
new results. What I would like to do is run the command again and have
the results append to the text file instead of completely rewriting the
text file. I have tried several hybrid commands using <fstreambut
nothing has worked yet. Thanks for any help.
这是一个操作系统依赖项,所以你应该在一个专门用于你的操作系统(或UNIX,你的shell)的组中询问。 < OT>在某些环境中,">>"
附加。< / OT>
干杯! --M
This is an OS dependency, so you should ask in a group dedicated to
your OS (or in UNIX, your shell). <OT>In some environments, ">>"
appends.</OT>
Cheers! --M
Reggie写道:
Reggie wrote:
我一直在使用system()命令将一个
程序的结果写入文件。这可以通过以下方式实现:
运行netstat例如:
system(" netstat example.txt");
当我再次运行命令时,它会使用
新结果完全重写文本文件。我想要做的是再次运行命令并将
结果附加到文本文件而不是完全重写
文本文件。我已经尝试了几个混合命令使用< fstreambut
什么都没有用。谢谢你的帮助。
I have been using the system() command to write the results of a
program to a file. This is being accomplished by the following when
running netstat for example:
system("netstat example.txt");
When I run the command again, it completely rewrites the text file with
new results. What I would like to do is run the command again and have
the results append to the text file instead of completely rewriting the
text file. I have tried several hybrid commands using <fstreambut
nothing has worked yet. Thanks for any help.
尝试
system(" netstat> example.txt");
谢谢和问候
SJ
Try
system("netstat >example.txt");
Thanks and regards
SJ
Reggie写道:
Reggie wrote:
system(netstat example.txt);
当我再次运行命令时,它会用
新结果完全重写文本文件。我想要做的是再次运行命令并将
结果附加到文本文件
system("netstat example.txt");
When I run the command again, it completely rewrites the text file with
new results. What I would like to do is run the command again and have
the results append to the text file
system(" netstat> ; example.txt");
-
Phlip
http://c2.com/cgi/wiki?ZeekLand < - 不是博客!!!
system("netstat >example.txt");
--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
这篇关于使用system()附加到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!