box-o-sand/lcthw-remnants/ex24_iofunctions05.c
Dan Buch f2380eef05 Add 'lcthw-remnants/' from commit 'e172f73c8297b22a579c94558f0c171ca74a0e5c'
git-subtree-dir: lcthw-remnants
git-subtree-mainline: 4107485591
git-subtree-split: e172f73c82
2013-01-09 23:42:19 -05:00

23 lines
428 B
C

#include <stdio.h>
#include "dbg.h"
int main(int argc, char *argv[])
{
FILE *fp;
char *filename;
check(argc == 2, "You must provide a filename for redirecting stdout.");
filename = argv[1];
fp = freopen(filename, "w", stdout);
check(fp != NULL, "Failed to reopen stdout as \"%s\"", filename);
printf("This should be written to the file you specified!\n");
return 0;
error:
return 1;
}