home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!spool.mu.edu!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!decwrl!pacbell.com!UB.com!pippen.ub.com!rfries
- From: rfries@sceng.ub.com (Robert Fries)
- Subject: Re: Turbo C FOPEN error
- Message-ID: <rfries.184@sceng.ub.com>
- Sender: news@pippen.ub.com (The Daily News)
- Nntp-Posting-Host: 128.203.1.151
- Organization: Ungermann Bass
- References: <1993Jan27.053643.21953@news.cs.brandeis.edu>
- Date: Thu, 28 Jan 1993 16:14:11 GMT
- Lines: 65
-
- In article <1993Jan27.053643.21953@news.cs.brandeis.edu> gilmour@binah.cc.brandeis.edu (Jeffrey R. Gilmour) writes:
-
- >I can't figure out what's wrong. This program works fine as long as there's
- >less than 16 files (it doesn't actually matter what drive). I haven't come
- >across anything explaining it in the manual. The error happens at runtime
- >during the 'stream = fopen(name...' line. Anybody?
-
- >/*
- >** FOPENERR.C
- >*/
- >
- >#include "stdio.h"
- >#include "io.h"
- >#include "dos.h"
- >
- >void main(void)
- >{
- > int done;
- > char name[15];
- > struct find_t test;
- > struct ftime ft;
- > FILE *stream;
- >
- > done = _dos_findfirst("a:*.*", _A_NORMAL, &test);
- > while (!done) {
- > strcpy(name, "a:");
- > strcat(name, test.name);
- > if ((stream = fopen(name, "r")) == NULL) {
- > printf("Error in opening filename.\n");
- > exit (1);
- > }
- >
- > getftime(fileno(stream), &ft);
- > printf("%-16s%7lu\t%2u/%02u/%u\n", name,
- > test.size, ft.ft_month,
- > ft.ft_day, ft.ft_year+1980);
- > done = _dos_findnext(&test);
- > }
- > fclose(stream);
- >}
-
- >___________________________________
- >|__/~~~~~\__/~~~~\__/~~~~\__/~~~~\_|/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
- >|____/~\____/~\_____/~\_____/~\____|\ /
- >|____/~\____/~~~\___/~~~\___/~~~\__|/ T h i s S p a c e f o r R e n t \
- >|____/~\____/~\_____/~\_____/~\____|\ /
- >|__/~~~\____/~~~~\__/~\_____/~\____|/ GILMOUR@BINAH.CC.BRANDEIS.EDU \
- >|__________________________________|\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
-
- Probably caused by having too many open files. Put the fclose(stream) call
- inside your loop; right after the call to getftime() looks like a good place.
-
- As it is, your program only explicitly closes the last file it opened,
- and all files are closed automatically when your program terminates.
-
- Robert
-
- //////////////////////////////////////////////////////////////////////////
- Robert Fries
- Ungermann-Bass Inc.
-
- DISCLAIMER:
- Opinions contained herein are my own, and are not necessarily those
- of Ungermann-Bass.
- //////////////////////////////////////////////////////////////////////////
-