home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20297 < prev    next >
Encoding:
Text File  |  1993-01-28  |  2.4 KB  |  66 lines

  1. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!csn!harpo.uccs.edu!sanluis!dbbergac
  2. From: dbbergac@sanluis (Dave Bergacker)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Turbo C FOPEN error
  5. Date: 27 Jan 1993 15:37:47 GMT
  6. Organization: University of Colorado at Colorado Springs
  7. Lines: 53
  8. Message-ID: <1k6a8bINNlip@harpo.uccs.edu>
  9. References: <1993Jan27.053643.21953@news.cs.brandeis.edu>
  10. NNTP-Posting-Host: sanluis.uccs.edu
  11. X-Newsreader: TIN [version 1.1 PL6]
  12.  
  13. Jeffrey R. Gilmour (gilmour@binah.cc.brandeis.edu) wrote:
  14. : I can't figure out what's wrong.  This program works fine as long as there's
  15. : less than 16 files (it doesn't actually matter what drive).  I haven't come
  16. : across anything explaining it in the manual.  The error happens at runtime 
  17. : during the 'stream = fopen(name...' line.  Anybody?
  18. : /*
  19. : **      FOPENERR.C
  20. : */
  21. :  
  22. : #include "stdio.h"
  23. : #include "io.h"
  24. : #include "dos.h"
  25. :  
  26. : void main(void)
  27. : {
  28. :         int done;
  29. :         char name[15];
  30. :         struct find_t test;
  31. :         struct ftime ft;
  32. :         FILE *stream;
  33. :  
  34. :         done = _dos_findfirst("a:*.*", _A_NORMAL, &test);
  35. :         while (!done) {
  36. :                 strcpy(name, "a:");
  37. :                 strcat(name, test.name);
  38. :                 if ((stream = fopen(name, "r")) == NULL) {
  39. :                         printf("Error in opening filename.\n");
  40. :                         exit (1);
  41. :                 }
  42. :  
  43. :                 getftime(fileno(stream), &ft);
  44. :                 printf("%-16s%7lu\t%2u/%02u/%u\n", name,
  45. :                         test.size, ft.ft_month,
  46. :                         ft.ft_day, ft.ft_year+1980);
  47. :                 done = _dos_findnext(&test);
  48. :         }
  49. :         fclose(stream);
  50. : }
  51. On a quick initial scan of the above, it would seem that you are exceeding
  52. the limit on the number of open files per executable.  If you put the
  53. fclose of the stream in the loop, perhaps you wouldn't have this problem.
  54. I am assuming that you just are interested in the open file for 1
  55. iteration of the loop since you re-use the FILE pointer stream.
  56.  
  57. --
  58. ___________________________________________________________________________
  59. | Dave Bergacker            |                  |
  60. | dbbergac@culebra.uccs.edu        | "I am NOT a merry man!"         |
  61. | Any opinions expressed are almost    | Lt. Worf, Enterprise Security   |
  62. | certainly not those of UCCS.        | "Have gahk, will travel"      |
  63. ---------------------------------------------------------------------------
  64.