Article View: comp.os.msdos.programmer
Article #7907Re: open vs fopen?
From: Harold E. Bamford
Date: Wed, 07 Feb 1996 00:06
Date: Wed, 07 Feb 1996 00:06
27 lines
1422 bytes
1422 bytes
In article <uEYFxc9nX8WX083yn@mbnet.mb.ca>, Nathan T. Wild <natewild@mbnet.mb.ca> wrote: >In C, why would one use open and DOS int handles rather than fopen and >stdio file handles? > >Is there some speed advantage or differnet functionality? open() is for raw I/O. You use read(), write(), lseek(), ltell() fopen() is for buffered I/O. You can use fread(), fscanf(), fgets(), getchar(), putchar, fprint(), fwrite(), fseek(), ftell(), etc. For certain applications, you can get away without buffering. But often it is easier to do the programming if you don't have to worry about unneeded system calls and buffering gives you that. Raw I/O is faster if you are, for instance, sucking the entire contents of a file into memory at once. Buffered I/O tends to automatically include parts of the standard C library that you may not need (*printf* stuff). It depends on your goal. And usually the reasons for using one or the other are operating system independent. -- Harold
Technical Details
Message-ID:
<4f8qf1$h3b@ssbunews.ih.att.com>Path:
arc1-ca.pugleaf.net!ssbunews.ih.att.com!not-for-mailReferences:
<uEYFxc9nX8WX083yn@mbnet.mb.ca>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!ssbunews.ih.att.com!not-for-mail From: bamford@marconi.ih.att.com (Harold E. Bamford) Newsgroups: comp.os.msdos.programmer,comp.lang.c Subject: Re: open vs fopen? Date: 7 Feb 1996 00:06:57 GMT Organization: AT&T Network Wireless Systems Business Unit Distribution: na Message-ID: <4f8qf1$h3b@ssbunews.ih.att.com> References: <uEYFxc9nX8WX083yn@mbnet.mb.ca> NNTP-Posting-Host: daneel.ih.att.com