| | |
System function, output to file
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Oct 2006
Posts: 11
Reputation:
Solved Threads: 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
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:
C++ Syntax (Toggle Plain Text)
int temp = system("last"); mystream << temp; cout << temp;
Last edited by Anonymusius; Nov 18th, 2006 at 3:19 am. Reason: BBcode
do it just like you would from the command line.
C++ Syntax (Toggle Plain Text)
system("dir > myfile.txt");
Last edited by Ancient Dragon; Nov 18th, 2006 at 8:55 am.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Oct 2006
Posts: 11
Reputation:
Solved Threads: 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.
C++ Syntax (Toggle Plain Text)
system("dir > myfile.txt");
![]() |
Similar Threads
- Redirecting console output to file (Java)
- system function in c++ (C++)
- how to make utilize of system( ) function (C)
- Please I need help formatting an output file and sorting the names! (C++)
Other Threads in the C++ Forum
- Previous Thread: Array problem
- Next Thread: problem with "for" statement
Views: 4388 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll download dynamic encryption error file forms fstream function functions game givemetehcodez google graph gui iamthwee ifstream input int integer java lib library linkedlist linker linux loop looping loops map math matrix memory microsoft newbie news number output parameter pointer problem program programming project python random read recursion recursive reference return sort stream string strings struct studio system template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






