file Length Cpp
Calculate the length of C++ - style files
Controller: CodeCogs
Interface
C++
FileLengthCpp
intfileLengthCpp( | std::fstream* | file | ) |
Example 1
#include <stdio.h> #include <codecogs/computing/io/binary/file_length.h> using namespace Computing::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
stream A 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)
References:
fileLengthExample 2
#include <iostream> #include <fstream> #include <codecogs/computing/io/binary/file_length_cpp.h> using namespace std; int main(int argc, char** argv) { if(argc < 2) return (-1); fstream a(argv[1]); cout <<"The file "<<argv[1] <<" is "<<fileLengthCpp(&a) <<"bytes long."<<endl; return (0); }
Parameters
file is a pointer referring to a C++ fstream object.
Returns
- fileLengthCpp returns the length of the input file in bytes. On failure it returns -1.
Authors
- Robert Schwede
Source Code
Source code is available when you agree to a GP Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.