Path: utzoo!utgpu!news-server.csri.toronto.edu!torsqnt!tmsoft!robohack!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Newsgroups: comp.lang.c Subject: Re: I/O redirection Message-ID: <1990Apr7.034117.2070@druid.uucp> Date: 7 Apr 90 03:41:17 GMT References: <1990Apr2.144841.12905@mentor.com> Reply-To: darcy@druid.UUCP (D'Arcy J.M. Cain) Organization: D'Arcy Cain Consulting, West Hill, Ontario Lines: 21 In article <1990Apr2.144841.12905@mentor.com> swhitchurch@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@druid) | Government: D'Arcy Cain Consulting | Organized crime with an attitude West Hill, Ontario, Canada | (416) 281-6094 |