Re: Help - I'm at wit's end...

From: BRG (brg_at_nowhere.org)
Date: 12/30/04


Date: Thu, 30 Dec 2004 00:05:19 +0000

Ben Pfaff wrote:
> BRG <brg@nowhere.org> writes:
>
>
>>Interesting - I was not aware that a 't' option existed - is this an
>>ANSI designated file opening mode?
>
>
> There is no `t' option--at least, not portably. No one
> interested in writing portable code would use `t', because it
> invokes undefined behavior. Here is the complete list from the
> C99 standard, section 7.19.5.3 paragraph 3:
>
> 3 The argument mode points to a string. If the string is one of
> the following, the file is open in the indicated
> mode. Otherwise, the behavior is undefined.228)
>
> r open text file for reading
> w truncate to zero length or create text
> file for writing
> a append; open or create text file for
> writing at end-of-file
> rb open binary file for reading
> wb truncate to zero length or create binary
> file for writing
> ab append; open or create binary file for
> writing at end-of-file
> r+ open text file for update (reading and
> writing)
> w+ truncate to zero length or create text
> file for update
> a+ append; open or create text file for
> update, writing at end-of-file
> r+b or rb+ open binary file for update (reading and
> writing)
> w+b or wb+ truncate to zero length or create binary
> file for update
> a+b or ab+ append; open or create binary file for
> update, writing at end-of-file

Thanks for the detail, which is most helpful.

   Brian Gladman



Relevant Pages

  • Re: Help - Im at wits end...
    ... > ANSI designated file opening mode? ... interested in writing portable code would use `t', ... invokes undefined behavior. ... The argument mode points to a string. ...
    (sci.crypt)
  • Re: Return pointer from function
    ... if (str) ... This function invokes undefined behavior when called with a whitespace-only ... string. ...
    (comp.lang.c)