Reputation: 12890
How to keep writing the results of system("ping 10.50.132.10 -t");
in a text file using C++?
Upvotes: 0
Views: 1840
Reputation: 409166
There are a couple solutions to this. The first and simplest would be to simple add a redirect in the system
call:
system("ping 10.50.132.10 -t > some_file.txt");
Another and more advanced way would be to read the output into your program, and write it out to file yourself. For this look either at _popen
or CreateProcess
.
Upvotes: 3
Reputation: 21520
A way is to do directly with shell command:
system("ping 10.50.132.10 -t >> file.txt");
After your operations, you can read from "file.txt"!
Upvotes: 5