prev up next   top/contents search

comp.lang.c FAQ list · Question 12.33

Q: How can I redirect stdin or stdout to a file from within a program?


A: Use freopen. If you're calling a function f() which writes to stdout, and you want to send its output to a file, and you don't have the option of rewriting f, you can use a sequence like:

	freopen(file, "w", stdout);
	f();
See, however, question 12.34.

References: ISO Sec. 7.9.5.4
H&S Sec. 15.2


prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North