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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:22:12+00:00 2026-06-03T20:22:12+00:00

I have a large text file. Each time my program runs, it needs to

  • 0

I have a large text file.
Each time my program runs, it needs to read in the first line, remove it, and put that data back into the bottom of the file.

Is there a way to accomplish this task without having to read in every part of the file?
It would be great to follow this example of pseudo code:

1. Open file stream for reading/writing
2.   data = first line of file
3.   remove first line from file  <-- can I do this?
4. Close file stream

5. Open file stream for appending
6.   write data to file
7. Close file stream

The reason I’m trying to avoid reading everything in is because the program runs at a specific time each day. I don’t want the delay to be longer each time the file gets bigger.

All the solutions I’ve found require that the program process the whole file. If C++ filestreams are not able to accomplish this, I’m up for whatever alternative is quick and efficient for my C++ program to execute.
thanks.

  • 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-03T20:22:14+00:00Added an answer on June 3, 2026 at 8:22 pm

    The unfortunate truth is that no filesystem on a modern OS is designed to do this. The only way to remove something from the beginning of a file is to copy the contents to a new file, except for the first bit. There’s simply no way to do precisely what you want to do.

    But hopefully you can do a bit of redesign. Maybe each entry could be a record in a database — then the reordering can be done very efficiently. Or perhaps the file could contain fixed-size records, and you could use a second file of indexes to specify record order, so that rearranging the file was just a matter of updating the indices.

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

Sidebar

Related Questions

I have a text file which contains a time stamp on each line. My
I have a simple text file that is ~150mb. My code will read each
What I have is an extremely large text file that needs to go into
I have a large file where each line contains space-separated integers. The task is
I have a rather large text file that has a bunch of missing newlines,
I have a large text file of records, each delimited by a newline. Each
I have a large text file I am reading from and I need to
I have a large text file in the format of. english word: spanish equivalent
I have a a large text file (over 70mb) and need to count the
Okay, basically, I have a large list of phone numbers in a text file

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.