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 7749685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:06:09+00:00 2026-06-01T11:06:09+00:00

I am writing a program that maintains a linked_list in a file. So I

  • 0

I am writing a program that maintains a linked_list in a file. So I traverse across the file, by using tellp()/tellg() and adding it to a particular long integer(can be seen as an offset) to get to the new location.

An simple example would be

   long next_offset =  sizeof(long) + sizeof(int) .... 
   //like size of all the elements in the record, etc

   curr_node = out.seekg();
   while(curr_node != -1) {
          out.read(...);
          **curr_node.seekg(curr_node.tellp() + next_offset);**
          out.read((char *)&curr_node,sizeof(long));
   }

so here basically I am saving tellp() value as long and dng an long addition, is this fine?? or is there a chance that I might lose some bits when the pos_value gets big???

  • 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-06-01T11:06:11+00:00Added an answer on June 1, 2026 at 11:06 am

    These values returned by tellp/tellg (streampos) are meant to store the maximum file size in the platform you’re using, so there’s no guarantee they will fit in a long. In fact, they may not fit in a size_t, long long, or whatever is the biggest fundamental type, since disk storage space is usually orders of magnitude larger than address space, and the fundamental types were defined with the later in mind.

    But IMO the practical thing to do is not to use another, bigger type unless you’re writing a program that really needs to handle huge files (like a DBMS or so), which is a rare case. If the maximum expected size fits in a long, simply put safeguards in your program to refuse to create or handle files bigger than that.

    On the other hand, if that’s indeed the case that you may have to handle enormous files, then things got a lot more complicated, and a comprehensive answer would be longer.

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

Sidebar

Related Questions

I'm writing a program that creates and edits directories and files in a file
Situation: I am writing a program in C that maintains a number of threads.
I'm writing a program that list the digits of integer input. example: Please enter
I'm writing a socket program that maintains FIFO queues for two input sockets. When
I am writing a program that creates an image file. I want the original
I am writing a program that reads data packets from a file, and assigns
I have tried writing program that plays a sound file but have been unsuccessful
Situation: I am writing a program in C that maintains a number of threads.
Im writing a program that should read input via stdin, so I have the
I am writing a program that generates a single large table of information. The

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.