Kyle R . Burton on Tue, 27 Nov 2001 22:40:16 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] c++ fs calls


> K&R 2nd Ed. has a simplistic cp program.  It's basically just a while
> loop using getchar and putchar.  ("while ((c = getchar()) != EOF)"...)
> Of course, it would be much more efficient to use read(2)/write(2) or
> fread(3)/fwrite(3); the latter are in stdio.h and the former are in
> unistd.h.  The major difference that I can see is that the former uses
> file descriptors while the latter uses (FILE *) structures.  BTW, is
> that the only real difference between them, or is there an advantage to
> one set over the other?

I beleive that the FILE* structs were designed as an object oriented 
interface on top of file descriptors (the open/close read/write calls).
The main differences are the functions that support each type of IO.  
The STDIO functions are more of an abstraction than the bare file descriptors
iirc.  The STDIO functions are ANSI C, and the file descriptor based
functions are no afaik.


k



-- 

------------------------------------------------------------------------------
Enter in.  Be one with the object of contemplation if you
wish to understand.  Don't be an outside observer of life.
Be life.
        -- T'ao-shan
mortis@voicenet.com                            http://www.voicenet.com/~mortis
------------------------------------------------------------------------------

______________________________________________________________________
Philadelphia Linux Users Group       -      http://www.phillylinux.org
Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce
General Discussion  -  http://lists.phillylinux.org/mail/listinfo/plug