home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!csn!harpo.uccs.edu!sanluis!dbbergac
- From: dbbergac@sanluis (Dave Bergacker)
- Newsgroups: comp.lang.c
- Subject: Re: Turbo C FOPEN error
- Date: 27 Jan 1993 15:37:47 GMT
- Organization: University of Colorado at Colorado Springs
- Lines: 53
- Message-ID: <1k6a8bINNlip@harpo.uccs.edu>
- References: <1993Jan27.053643.21953@news.cs.brandeis.edu>
- NNTP-Posting-Host: sanluis.uccs.edu
- X-Newsreader: TIN [version 1.1 PL6]
-
- Jeffrey R. Gilmour (gilmour@binah.cc.brandeis.edu) wrote:
- : 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);
- : }
- :
- On a quick initial scan of the above, it would seem that you are exceeding
- the limit on the number of open files per executable. If you put the
- fclose of the stream in the loop, perhaps you wouldn't have this problem.
- I am assuming that you just are interested in the open file for 1
- iteration of the loop since you re-use the FILE pointer stream.
-
- --
- ___________________________________________________________________________
- | Dave Bergacker | |
- | dbbergac@culebra.uccs.edu | "I am NOT a merry man!" |
- | Any opinions expressed are almost | Lt. Worf, Enterprise Security |
- | certainly not those of UCCS. | "Have gahk, will travel" |
- ---------------------------------------------------------------------------
-