fopen() and memory shortage

Chip Salzenberg chip at tct.uucp
Sat Feb 10 01:07:24 AEST 1990


According to reznick at ribs.UUCP (Larry Reznick):
>Try using the stat() function, which gives directory information for a
>pathname without opening the file.  Your fexist() function would use
>stat() to determine if the file exists.

However, Larry then goes on to mention:

>The open()/close() functions are not standard; fopen()/fclose() are.
>Using open()/close() may impact portability.

Using stat() will impact portability even more.  If you need to
conserve memory, just be sure to call "setbuf(fp, (char *)NULL)" after
the fopen() call(s) in question.  An endearing characteristic of
unbuffered streams is that they don't need to allocate buffers.  :-)
-- 
Chip Salzenberg at ComDev/TCT   <chip%tct at ateng.com>, <uunet!ateng!tct!chip>
          "The Usenet, in a very real sense, does not exist."



More information about the Comp.lang.c mailing list