0

(c++)
Ok so I understand how to use the system function, and how to output to a file. How do I pipe the output of say system("last") to a file?
system() returns an int, so if I mystream << system("last") it will put an int in the file. I need to intercept the output going to the screen(cout?) and put it in the file (mystream? or can I do this in the last command with some parameters?)

Thanks

3
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by balgarath
0

If I correctly understand what you say would that be:

int temp = system("last");
mystream << temp;
cout << temp;
0

Thanks that got it. I didn't know that one but I do now. Appreciate the help.

do it just like you would from the command line.

system("dir > myfile.txt");
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.