This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/ftell.c

24 lines
419 B
C

#include <stdio.h>
long int filesize( FILE *fp )
{
long int save_pos, size_of_file;
save_pos = ftell( fp );
fseek( fp, 0L, SEEK_END );
size_of_file = ftell( fp );
fseek( fp, save_pos, SEEK_SET );
return( size_of_file );
}
void main()
{
FILE *fp;
fp = fopen( "file", "r" );
if( fp != NULL ) {
printf( "File size=%ld\n", filesize( fp ) );
fclose( fp );
}
}