-
putting output to a file
Hi all,
I have aproblem with a program, and i hope someone can halp me out....
I want to put the output, wich i see on the dos console, on a txt file.
I know i can do that with fputs, but i think its a very long procedure to build in the fputs line after each printf line i want to see on the file.
Isn't there some other way, to put the whole output on a txt file?
(I also want to keep seeing it on my console too !) .
Isn't there a command, wich copies the screen on the file?
Can somebody help me out ?
Thanks in advance...
-
myprog.exe
This displays on the screen
myprog.exe > file.txt
This stores the output in a file.
If you want to see both at the same time, write your code better or get Unix/Linux :)
myprog.exe | tee file.txt
This stores output in file.txt AND also displays on the screen.
>but i think its a very long procedure to build in the fputs line after each printf line
Well it's not to hard to do this
Code:
int myprintf ( const char *format, ... ) {
// some magic using vsprintf
if ( outputfile ) {
fputs( buff, outputfile );
}
fputs( buff, stdout );
}
-
Thank you for replying, but can i put in "myprog.exe > file.txt " in the program?
I think its a command to use in the dosconsole, before the prompt....
Can i build that also in?
-
Sure, you implement "myprintf" as shown, and call it.