26 lines
421 B
C
26 lines
421 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 );
|
|
}
|
|
}
|
|
|