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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:59:46+00:00 2026-06-18T07:59:46+00:00

Is it safe to open an input stream to a file, while an output

  • 0

Is it safe to open an input stream to a file, while an output stream to the same file is open (but not writing to it)
(Single threaded)

  • 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-18T07:59:47+00:00Added an answer on June 18, 2026 at 7:59 am

    Partially, it depends on the system. The system may not allow it. Other than that, as soon as you have a stream open for writing, and more than one stream open on the same file (regardless of direction), you have to worry about buffering. In your case, if you do a flush before opening the stream for reading, and do not write while you’re reading, it should be OK. If you’re trying to write, and read the last thing you wrote, it is more difficult, because there is nothing which you can do to resynchronize a read buffer with the file. And if you’re trying to write through two different streams, it’s even more problematic. (Although if the writes should always be appended at the end, and you can arrange when you flush, opening the files with std::ios_base::app should do the trick. But that won’t help reading.)

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

Sidebar

Related Questions

I read that for images, it's not safe to depend on the file extension
Is there any process safe logging library which can write same file from multiple
I have a method (a .yml parser) that takes an input stream as input.
If I want to open a TCP socket between 2 processes on the same
I have two binary files equal in size, but not in values. I used
Possible Duplicate: PHP Configuration: It is not safe to rely on the system’s timezone
Microsoft played safe here. In their article, Creating a Child Process with Redirected Input
I had a small crash but had all the data in safe storage. But
I have posted the following code where I am reading from an input file
How to save class object to file and then encrypt it with open and

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.