mod.std.c Digest V8#7

Orlando Sotomayor-Diaz osd at hou2d.UUCP
Sat Jul 13 02:40:13 AEST 1985


From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>


mod.std.c Digest            Fri, 12 Jul 85       Volume 8 : Issue   7 

Today's Topics:
                            flag to fopen
                  note on & operator change (2 msgs)
----------------------------------------------------------------------

Date: Thu, 11 Jul 85 23:13:22 edt
From: decvax!minow (Martin Minow)
Subject: flag to fopen
To: std-c at cbosgd

I'm pretty sure I remember seeing such a flag in the current
Draft Standard:

	fd = fopen(filename, "rb");	/* read binary */
	fd = fopen(filename, "wb");	/* write binary */

There were a few other new flags.  Decus C has had such a flag
for 7 years or so (different letter, however).  As noted, it
is slightly painful on stdin/stdout.  However, in Decus C,
you can do the following:

	char	filename[256];

	fgetname(filename, stdin);	/* get name of file on stdin */
	freopen(filename, "rb" stdin);	/* and force it to binary */

Martin Minow
decvax!minow

PS: here are the fopen flags (from the April 30 draft):

r	open text file for reading
w	create text file for writing or truncate
a	append; open text file or create for writing at end of file
rb	open binary file for reading [also wb, ab]
r+	open text file for update [also w+, a+]
r+b	open binary file for update [also w+b, a+b]

------------------------------

Date: 6 Jul 85 05:50:48 CDT (Sat)
From: ihnp4!trwrb!desint!geoff
Subject: note on & operator change
To: trwrb!ihnp4!cbosgd!std-c

In article <567 at hou2d.UUCP> elsie!ado writes:

>Date: Wed, 19 Jun 85 19:29:25 EDT
>From: seismo!elsie!ado
>Subject: UNIX/WORLD note on & operator change
>
>...allowing the & operator to be applied to
>arrays will NOT allow time_t to be typedefed to an array, since variables of
>type time_t are returned by standard functions (the function "time" in
>particular)--and functions are not allowed to return arrays.  Folks interested
>in seeing the problem concretely can run these two lines:
>	typedef int	time_t[2];
>	extern time_t time();
>through their favorite C compiler.

But it's easy to do this:

	typedef struct {int timedat[99];} time_t;
	extern time_t time ();

(Obviously this requires a compiler that can return structures from functions,
but I believe this is in the standard too.)
-- 

	Geoff Kuenning
	...!ihnp4!trwrb!desint!geoff

------------------------------

Date: Thu, 11 Jul 85 10:28:26 EDT
From: seismo!elsie!ado
Subject: note on & operator change
To: std-c at cbosgd, inhp4!trwrb!desint!geoff

> But it's easy to do this:
>	typedef struct {int timedat[99];} time_t;
>	extern time_t time ();

Indeed it is easy to do the above.  And if the above is done, there's no need
to change the language to allow & to be applied to arrays--a change which, as
my first contribution noted, is insufficient to allow time_t to be typedefed to
an array.  So:  I'd like to see the committee abandon the notion of allowing
& to be applied to arrays.

				--ado

------------------------------

End of mod.std.c Digest - Fri, 12 Jul 85 09:12:11 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c at BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.



More information about the Mod.std.c mailing list