Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Historical question, why fwrite and not binary specifier for fprintf?

Reply
Thread Tools

Historical question, why fwrite and not binary specifier for fprintf?

 
 
Richard Tobin
Guest
Posts: n/a
 
      11-28-2007
In article <1196265404.5351@news1nwk>,
Eric Sosman <(E-Mail Removed)> wrote:

>> In the beginning (Kernighan & Ritchie 197 there was fprintf, and unix
>> write, but no fwrite. That is, no portable C method for writing binary
>> data, only system calls which were OS specific.


> There was putc(), which is portable.


To be pedantic, in 1978 there was indeed putc(), but it wasn't the
putc() we know today. The then-current sixth edition unix used a
pointer to a 518-byte "struct buf", which the programmer had to
create, instead of the opaque FILE struct introduced in seventh
edition (1979) along with most of the stdio functions we use today.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      11-28-2007
Richard Tobin wrote On 11/28/07 13:00,:
> In article <1196265404.5351@news1nwk>,
> Eric Sosman <(E-Mail Removed)> wrote:
>
>
>>>In the beginning (Kernighan & Ritchie 197 there was fprintf, and unix
>>>write, but no fwrite. That is, no portable C method for writing binary
>>>data, only system calls which were OS specific.

>
>
>> There was putc(), which is portable.

>
>
> To be pedantic, in 1978 there was indeed putc(), but it wasn't the
> putc() we know today. The then-current sixth edition unix used a
> pointer to a 518-byte "struct buf", which the programmer had to
> create, instead of the opaque FILE struct introduced in seventh
> edition (1979) along with most of the stdio functions we use today.


To be pedantic back at'cha: putc() and FILE and fopen()
and so on are described in Chapter 7 of "The C Programming
Language" by Brian W. Kernighan and Dennis M. Ritchie, ISBN
0-13-110163-3. The copyright date is 1978, not 1979 or later,
and the putc() description is on page 152.

Perhaps Unix lagged C by a year or so?

--
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      11-28-2007
In article <1196277214.437935@news1nwk>,
Eric Sosman <(E-Mail Removed)> wrote:

> To be pedantic back at'cha: putc() and FILE and fopen()
>and so on are described in Chapter 7 of "The C Programming
>Language" by Brian W. Kernighan and Dennis M. Ritchie, ISBN
>0-13-110163-3. The copyright date is 1978, not 1979 or later,
>and the putc() description is on page 152.
>
> Perhaps Unix lagged C by a year or so?


I was relying on the date of the unix manuals. I don't think there
was anything except unix to run C on back then. Perhaps the updated
library was available was available before the new version of unix, or
perhaps the book was written before the corresponding software was
generally available. (I don't seem to have my K&R1 to hand to see if
it says anything about it.)

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
 
Reply With Quote
 
J. J. Farrell
Guest
Posts: n/a
 
      11-29-2007
Richard Tobin wrote:
> In article <1196277214.437935@news1nwk>,
> Eric Sosman <(E-Mail Removed)> wrote:
>
>> To be pedantic back at'cha: putc() and FILE and fopen()
>> and so on are described in Chapter 7 of "The C Programming
>> Language" by Brian W. Kernighan and Dennis M. Ritchie, ISBN
>> 0-13-110163-3. The copyright date is 1978, not 1979 or later,
>> and the putc() description is on page 152.
>>
>> Perhaps Unix lagged C by a year or so?

>
> I was relying on the date of the unix manuals. I don't think there
> was anything except unix to run C on back then. Perhaps the updated
> library was available was available before the new version of unix, or
> perhaps the book was written before the corresponding software was
> generally available. (I don't seem to have my K&R1 to hand to see if
> it says anything about it.)


UNIX v7 was released in January 1979; I guess that K&R1 was written
based on what was being put together for UNIX v7. Given the difference
between copyright and release dates, it's quite possible that UNIX v7
was finished within Bell Labs before K&R1 was finished.

UNIX v6 had primitive versions of putc() and fopen() which do not match
the definitions in K&R1 or UNIX v7. The Standard I/O library as we know
it today is based on that in UNIX v7 as described in K&R1.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fwrite, fgets binary file readback problem Jeff C Programming 16 06-09-2008 12:03 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
why typedef is storeage class specifier sunny C Programming 1 10-18-2006 12:39 PM
why Typedef is storage class specifier? sunny C Programming 1 10-16-2006 07:53 PM
Very strange problem using FWRITE() to write data to a binary file leonecla@yahoo.it C Programming 6 02-09-2005 06:06 PM



Advertisments