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

  • Home
  • SEARCH
  • 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 8668441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:12:52+00:00 2026-06-12T18:12:52+00:00

how do I seek beyond end of existing file ? Consider I have test.bin

  • 0

how do I seek beyond end of existing file ?

Consider I have test.bin which is 1000 bytes.

Then I run following

std::filebuf fbuf;
fbuf.open("c:\\test.bin", std::ios_base::in | std::ios_base::out | std::ios_base::app | std::ios_base::binary);
fbuf.pubseekoff(10, std::ios_base::end);
fbuf.sputc(1);
fbuf.close();

After running this example I expect new filesize to be 1011 bytes. But instead it adds 0x01 at the end of existing file making it 1001 bytes.

Interestingly though it works the way I want it when it’s new file.

I’m running this on Windows 7 x64 but target platform will be Ubuntu.

  • 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-12T18:12:53+00:00Added an answer on June 12, 2026 at 6:12 pm

    You set the std::ios_base::app flag. This causes all writes to occur at the end of the file. If you want writes to be performed at the current position, you cannot specify this flag when you open the file.

    ios_base::app Append file; that is, always write to the end of the file

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

Sidebar

Related Questions

I'm string to seek in a remotely hosted FLV file and have it stream
I need a seek bar which color need this I made an xml file
I would like seek some guidance in writing a process profiler which runs in
I am using MFC CFile Seek function. I have a problem about Seek out
The following query uses an index seek on an index on the LastModifiedTime column.
It seems seek() on mp4 file seeks to the closest keyframe (seekpoint). Is it
I have a screen with 4 seek bars ( As shown in the image
I have very little knowledge in testing and I wish to seek guidance in
I have created a custom field class Seek to draw a fillrectangle. class Seek
I have a query that has a very costly INDEX SEEK operation in 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.