You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
box-o-sand/oldstuff/lcthw-remnants/ex24_iofunctions05.c

23 lines
428 B

#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;
}