home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / question / 13295 < prev    next >
Encoding:
Text File  |  1992-11-12  |  877 b   |  24 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!hela.iti.org!usc!rpi!cecchinr
  3. From: cecchinr@hornsby.cs.rpi.edu (Ron Cecchini)
  4. Subject: Getting a file's size with the FILE data structure
  5. Message-ID: <l=r19z_@rpi.edu>
  6. Nntp-Posting-Host: hornsby.cs.rpi.edu
  7. Organization: Rensselaer Polytechnic Institute, Troy, NY
  8. Date: Thu, 12 Nov 1992 21:14:35 GMT
  9. Lines: 13
  10.  
  11. Hi again,
  12.  
  13.  I found that you can use the FILE ds to get a file's size.  However,
  14. there seems to be a glitch with it.  For one, the data structure is
  15. NOT initialized after the fopen().  So, thats no good.  And you can't try
  16. to fseek() to the beginning and look at ->_cnt.  What I found you have to do
  17. is: fgets() a line from the file and *THEN* fseek() back to the beginning
  18. of the file.  *NOW* ->_cnt contains the size of the file.
  19.  
  20. Ron
  21.  
  22. p.s. I have received info on using the stat() command to also get the info.
  23.  
  24.