Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #66069

Re: stdin and stdout

From Bartc <bc@freeuk.com>
Newsgroups comp.lang.c
Subject Re: stdin and stdout
Date 2015-07-20 23:06 +0100
Organization A noiseless patient Spider
Message-ID <mojran$ccc$1@dont-email.me> (permalink)
References <moitgi$g2j$1@dont-email.me> <lnsi8ig09w.fsf@kst-u.example.com> <mojf3u$q45$1@dont-email.me> <lnbnf6fvsf.fsf@kst-u.example.com>

Show all headers | View raw


On 20/07/2015 20:56, Keith Thompson wrote:
> Bartc <bc@freeuk.com> writes:
>> On 20/07/2015 19:19, Keith Thompson wrote:
>>> Bartc <bc@freeuk.com> writes:
>>
>>>> I thought there might be a function that returned the values or a
>>>> pointer to them.
>>>
>>> There's no standard function that does this -- nor is there anything
>>> stopping you from writing such a function yourself.
>>
>> How? (Other than solutions based on passing special files/paths to fopen.)
>
> #include <stdio.h>
>
> FILE *stdin_func(void)  { return stdin; }
> FILE *stdout_func(void) { return stdout; }
> FILE *stderr_func(void) { return stderr; }
>
> I don't know enough about what you're doing to know whether that's a
> solution.

The problem is that there might be two C runtime libraries (one linked 
normally, the other loaded independently at runtime). They could be 
different libraries, or possibly the same one, but it thinks there are 
two different instances of itself.

The stdin/stdout in your code will only correspond to one of those. If 
you call the fprintf of one library, with the stdout of the other, I 
don't know what will happen.

(Another issue is if that C library is accessed by a program that 
doesn't use C source code, then 'stdin' etc are not available. Actually, 
for this kind of reason, I try and ensure one module is pure C. Although 
this doesn't help with the above problem.

I will use the fopen("con") kind of solution or that.)

-- 
Bartc

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

stdin and stdout Bartc <bc@freeuk.com> - 2015-07-20 14:37 +0100
  Re: stdin and stdout Richard Heathfield <rjh@cpax.org.uk> - 2015-07-20 14:58 +0100
    Re: stdin and stdout Bartc <bc@freeuk.com> - 2015-07-20 15:31 +0100
      Re: stdin and stdout Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-20 16:29 +0100
        Re: stdin and stdout Bartc <bc@freeuk.com> - 2015-07-20 17:03 +0100
      Re: stdin and stdout Ken Brody <kenbrody@spamcop.net> - 2015-07-20 12:09 -0400
      Re: stdin and stdout Lőrinczy Zsigmond <zsiga@nospam.for.me> - 2015-07-21 10:02 +0200
  Re: stdin and stdout Keith Thompson <kst-u@mib.org> - 2015-07-20 11:19 -0700
    Re: stdin and stdout Bartc <bc@freeuk.com> - 2015-07-20 19:38 +0100
      Re: stdin and stdout Keith Thompson <kst-u@mib.org> - 2015-07-20 12:56 -0700
        Re: stdin and stdout Bartc <bc@freeuk.com> - 2015-07-20 23:06 +0100
          Re: stdin and stdout glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-07-20 23:18 +0000
            Re: stdin and stdout BGB <cr88192@hotmail.com> - 2015-07-21 14:12 -0500
          Re: stdin and stdout gordonb.9oj0u@burditt.org (Gordon Burditt) - 2015-07-21 19:14 -0500
            Re: stdin and stdout Bartc <bc@freeuk.com> - 2015-07-22 11:11 +0100
              Re: stdin and stdout gordonb.3xos3@burditt.org (Gordon Burditt) - 2015-07-22 20:05 -0500
                Re: stdin and stdout Bartc <bc@freeuk.com> - 2015-07-23 09:27 +0100
          Re: stdin and stdout Richard Damon <Richard@Damon-Family.org> - 2015-07-21 21:44 -0400
            Re: stdin and stdout glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-07-22 04:10 +0000
      Re: stdin and stdout BGB <cr88192@hotmail.com> - 2015-07-21 12:55 -0500
        Re: stdin and stdout Bartc <bc@freeuk.com> - 2015-07-21 20:49 +0100
          Re: stdin and stdout BGB <cr88192@hotmail.com> - 2015-07-22 00:05 -0500
            Re: stdin and stdout "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-22 02:48 -0700
              Re: stdin and stdout "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-22 02:57 -0700
                Re: stdin and stdout gordonb.bjmxp@burditt.org (Gordon Burditt) - 2015-07-22 20:27 -0500
              Re: stdin and stdout BGB <cr88192@hotmail.com> - 2015-07-22 13:19 -0500
                Re: stdin and stdout Robert Wessel <robertwessel2@yahoo.com> - 2015-07-22 18:09 -0500

csiph-web