Article View: comp.sys.ibm.pc.programmer
Article #262Re: Turbo C File Size Routines:
From: Stephen M. Dunn
Date: Mon, 09 Apr 1990 05:35
Date: Mon, 09 Apr 1990 05:35
27 lines
1321 bytes
1321 bytes
Well, I don't know if TC provides a function to determine the length
of the file, but you can certainly use ftell() to find your current
position and something similar to the following to determine the length
of the file if it doesn't (and the following should be portable to all
C compilers - it will certainly work on anything that accepts ANSI C).
#include <stdio.h>
long filelength (FILE *fp)
{
long current_position = ftell (fp);
long length_of_file;
fseek (fp, 0, SEEK_END);
length_of_file = ftell (fp);
fseek (fp, current_position, SEEK_SET);
return length_of_file;
}
Please excuse any typos ...
--
More half-baked ideas from the oven of:
****************************************************************************
Stephen M. Dunn cs4g6ag@maccs.dcss.mcmaster.ca
<std_disclaimer.h> = "\nI'm only an undergraduate ... for now!\n";
Technical Details
Message-ID:
<26201F3B.1118@maccs.dcss.mcmaster.ca>Path:
arc1-ca.pugleaf.net!utzoo!attcan!lsuc!maccs!cs4g6agReferences:
<3263@bingvaxu.cc.binghamton.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!lsuc!maccs!cs4g6ag From: cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) Newsgroups: comp.sys.ibm.pc.programmer Subject: Re: Turbo C File Size Routines: Message-ID: <26201F3B.1118@maccs.dcss.mcmaster.ca> Date: 9 Apr 90 05:35:55 GMT References: <3263@bingvaxu.cc.binghamton.edu> Organization: McMaster University, Hamilton, Ontario Lines: 27