home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- From: sff@mobrad.demon.co.uk.demon.co.uk (Sean Fitt)
- Path: sparky!uunet!digex.com!intercon!udel!bogus.sura.net!howland.reston.ans.net!spool.mu.edu!agate!doc.ic.ac.uk!pipex!demon!mobrad.demon.co.uk.demon.co.uk!sff
- Subject: Re: Turbo C FOPEN error
- Reply-To: sff@mobrad.demon.co.uk.demon.co.uk
- References: <1993Jan27.053643.21953@news.cs.brandeis.edu>
- Distribution: world
- X-Mailer: cppnews $Revision: 1.30 $
- Organization: Mobile Radio Limited
- Lines: 52
- Date: Wed, 27 Jan 1993 17:21:28 +0000
- Message-ID: <728180488snx@mobrad.demon.co.uk.demon.co.uk>
- Sender: usenet@demon.co.uk
-
- In article <1993Jan27.053643.21953@news.cs.brandeis.edu> gilmour@binah.cc.brandeis.edu 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?
-
- [Part of Program deleted]
-
- > 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);
-
- [Rest Deleted]
-
- Your problem is you're not closing the file after obtaining the information
- you require - you're closing *one* file at the end of the program. What this
- means in real terms is that you're exceeding the maximum number of files
- which can be opened at any one time.
-
- Try moving the 'fclose(stream)' line to just before the
- 'done = _dos_findnext(&test)' line, and it should work.
- i.e.
- printf("%-16s%7lu\t%2u.%02u/%u\n", name
- test.size, ft.ft_month,
- ft.ft_day, ft.ft_year+1980);
- fclose(stream);
- done = _dos_findnext(&test);
-
- Sean.
-
- ==============================================================================
- | Sean Fitt | My views are those with which I was |
- | sff@mobrad.demon.co.uk | indoctrinated from a very early age. |
- | naffcode@cix.compulink.co.uk | Please don't blame me if you don't |
- | 100034.2166@compuserve.com | agree with them. |
- |----------------------------------------------------------------------------|
- | demon is a subscription site, and mobrad are not connected or related in |
- | any way to any other demon subscribers |
- ==============================================================================
-