(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

If I correctly understand what you say would that be:

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

do it just like you would from the command line.

system("dir > myfile.txt");

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");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.