I/O redirection

D'Arcy J.M. Cain darcy at druid.uucp
Sat Apr 7 13:41:17 AEST 1990


In article <1990Apr2.144841.12905 at mentor.com> swhitchurch at mentor.com (Steve Whitchurch) writes:
>Hi;
>
>I have a question: I need to change or redirect "stdout" from inside
>a C function. What I want to do is capture the output of a printf and
>put the results into a file. so it would go something like this:
>
> redirect_stdout ();
> call_function_that_prints_to_stdout ();
> reset_stdout ();
>
> Is there a way in C that I can do this ?????????? Change where stdout
> goes ???????

It's even easier than you think.  Use fprintf (see printf(3S))

-- 
D'Arcy J.M. Cain (darcy at druid)     |   Government:
D'Arcy Cain Consulting             |   Organized crime with an attitude
West Hill, Ontario, Canada         |
(416) 281-6094                     |



More information about the Comp.lang.c mailing list