Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,166 questions

40,722 answers

573 users

How to get the size of a binary file in C

Booking.com | Official site | The best hotels, flights, car rentals & accommodations


96 views
asked Oct 18, 2014 by avibootz
edited Aug 2, 2015 by avibootz

1 Answer

0 votes
#include <stdio.h>
 
int main(void)
{
    long fsize;
    FILE *fp;

    fp = fopen("d:\\data.bin","rb");
    if (!fp)
    {
        printf("Unable to open file");
        return 1;
    }
    fseek (fp , 0 , SEEK_END);
    fsize = ftell(fp);
    
    printf("file size = %ld", fsize);
    fclose(fp);
 
    return 0;
}

/*
run: (the size of d:\\date.bin)

file size = 12

*/




answered Oct 18, 2014 by avibootz

Related questions

1 answer 111 views
111 views asked Dec 22, 2015 by avibootz
1 answer 198 views
1 answer 69 views
...