iobinary

File Length

Available under GPL (Free) and Commercial licence
get a GPL licence
COST (GBP)
this unit 0.90
sub units 0.00
add a commercial licence to your cart
0
viewed 10272 times and licensed 149 times
www.codecogs.com/d-ox/io/binary/file_length.php
Controller: CodeCogs    Contact Controller

Interface

#include <codecogs/io/binary/file_length.h>

using namespace IO::Binary;

long fileLength (FILE* stream)
Calculates the length of a binary file.

Function Documentation

 
longfileLengthFILE*stream )
Returns the length of a file in bytes. Useful when you need to dynamically allocate memory to hold the contents of a file you intend to read. This function was designed to replicated the similarly named filelength function that comes with some distributions of C/C++, particularly on DOS platforms. There doesn't appear to be an equivalent in Unix.
Example:
#include <stdio.h>
#include <codecogs/io/binary/file_length.h>
 
using namespace IO::Binary;
 
int main ()
{
  FILE* stream = fopen("/codecogs/io/binary/file_length.h","rb");
  printf("\n File length=%d", fileLength(stream));
  fclose(stream);
 
  return 0;
}
Parameters:
streamA pointer to the file stream
Returns:
The length of the file in bytes. Return -1 if an error is encountered.
Authors:
Will Bateman (March 2005)
Source Code:
Register

- To get code register with CodeCogs. Already a Member, then Login.


Last Modified: 18 Oct 07 @ 17:07     Page Rendered: 2008-05-13 19:36:45

Page Comments

  You must login to leave a messge


Valid CSS!   Valid XHTML 1.0 Transitional