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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:55:46+00:00 2026-06-12T08:55:46+00:00

This is the loop I have for reading from a file of any size,

  • 0

This is the loop I have for reading from a file of any size, and writing to a 1016 byte char* packet 1016 bytes each time then sending it (sending not included yet).

Is the seekg() necessary? Or does reading move the pointer to the front of the next chunk already?

ifstream file (packet.message, ios::in|ios::binary|ios::ate);
if(file.is_open()) {
    size = file.tellg();
    file.seekg(0, ios::beg);
    for(int i = 0; !ios::eof; i++) {
        memset(packet.message,0,1016*sizeof(char));
        file.read(packet.message,1016*sizeof(char));
        file.seekg(i*1016*sizeof(char));
    }
}

I know this isn’t an issue for writing to a file, since you just keep writing to the end until the file is the right size.

Edit: added the whole bit of code in the if statement.

  • 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-12T08:55:47+00:00Added an answer on June 12, 2026 at 8:55 am

    It’s not necessary. Reading continues from where the file pointer was last seen, exactly like writing does.

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

Sidebar

Related Questions

basically i am reading image bytes from file i have a loop which has
I have loop and each iteration of Hash looks like this: [1, {:clid=>1, :nvz=>4,
I have a for each loop like this $sn_count = 1; $prodfilter = ;
I have this very huge XML file of size 2.8GB. This is Polish Wikipedia's
I have a code where I am reading all the lines from the file
I'm constantly reading from a memory mapped file another process is writing to and
This is a follow-up of this question: Ada: reading from a file . I
I'm reading positional records from a text file, for examle, it looks like this:
I have a C program where I'm reading in from a file and then
I have this loop method to display a ViewPager and I set an OnClickListener

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.