Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7009531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:52:26+00:00 2026-05-27T21:52:26+00:00

I created below code in a Objective C program to get the size of

  • 0

I created below code in a Objective C program to get the size of a file in a directory and I must do it in C without using any Objective-C methods. This works fine and gives the correct size when checking it with small size files. But when it comes to large files (tested with 7GB file) this size variable returns the size of the file as 0. Can anyone help me to solve this issue?

//filePath is a string parameter which takes the path of the file
    FILE *fp=nil;
    const char  *filePathInToChar = [filePath UTF8String];
    fp = fopen(filePathInToChar, "rb");
    fseek(fp, 0, SEEK_END);
    long size = ftell(fp);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:52:27+00:00Added an answer on May 27, 2026 at 9:52 pm

    Your problem is that ftell returns the current position in the filestream as long int which on a 32bit system has usually a maximum value of 2^31 – or 2GB in other words.

    You can use stat (so you don’t actually need to open and close the file):

    #include <sys/stat.h>
    
    struct stat buf;
    stat(filePathInToChar, &buf);
    off_t size = buf.st_size;
    

    off_t should be long long which is usually 64bit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created two tabs in my Activity using the below code. This is
i've created an rss feed in php using the below code. i've double checked
I have created uitabbarview controller using the below code In the uitabbar controller i
I created a DatePicker user control (ASP code below, no code behind) which is
In my code I have 2 ComboBox DropDownLists, created by the code below. The
How to drag and drop the dynamically created controls my code is shown below
I have a dialog box, created with the code javascript and HTML generated below.
I am using below code to create a reminder in Google calendar (using Google
I am using jquery to create a custom dropdown with the code below. I
I'm having kind of a dumb problem. I am using the below code to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.