How do you redirect output in Windows using C?
I tried doing "./echo > myfile.txt", but it wouldn't work.
myfile.txt", but it wouldn't work." /> myfile.txt", but it wouldn't work." /> myfile.txt", but it wouldn't work."/>
How do you redirect output in Windows using C?
I tried doing "./echo > myfile.txt", but it wouldn't work.
Great Info here: http://www.robvanderwoude.com/redirection.php
Short Extract:
command > file
| Write standard output of command to file
command 1> file
| Write standard output of command to file (same as previous)
command 2> file
| Write standard error of command to file (OS/2 and NT)
command > file 2>&1
| Write both standard output and standard error of command to file (OS/2 and NT)
command >> file
| Append standard output of command to file
command 1>> file
| Append standard output of command to file (same as previous)
command 2>> file
| Append standard error of command to file (OS/2 and NT)
command >> file 2>&1
| Append both standard output and standard error of command to file (OS/2 and NT)
commandA | commandB
| Redirect standard output of commandA to standard input of commandB
commandA 2>&1 | commandB
| Redirect standard output and standard error of commandA to standard input of commandB (OS/2 and NT)
command < file
| command gets standard input from file
command 2>&1
| command's standard error is redirected to standard output (OS/2 and NT)
command 1>&2
| command's standard output is redirected to standard error (OS/2 and NT)
Ps. No need for slashes...
Just use
echo.exe > myfile.txt
and
echo.exe >> myfile.txt
to append to fileconsidering
echo.exe
is your executable