473,699 Members | 2,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

flush on close()?

Hello, just a simple question:
Does the close() method of an ofstream object always flush the buffer?

Thanks for answers.
Phil

Jul 22 '05 #1
2 1843

"Philipp" <no************ *@hotmail.com> wrote in message
news:41******** @epflnews.epfl. ch...
Hello, just a simple question:
Does the close() method of an ofstream object always flush the buffer?

Thanks for answers.
Phil


Of course it does ! No written characters or data are lost.

The operating system might not follow this same ideea. It is free to decide
that the file is on a fixed drive that won't go anywhere and that caching it
until the next disk write is worthy

Timothy Madden
Romania
-------------------------------
And I don't wanna miss a thing
Jul 22 '05 #2

"Philipp" <no************ *@hotmail.com> wrote in message
news:41******** @epflnews.epfl. ch...
Hello, just a simple question:
Does the close() method of an ofstream object always flush the buffer?


No, not always, but when needed (e.g. the last write operation
might have already caused a flush). You can be assured that
(barring errors) everything has been written after closing
an output stream.

-Mike
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2845
by: Tony | last post by:
OK - let's get the IE bashing out of the way... <space provided to bash IE> </space> On to the problem: I have a query that I'm running on a test server that takes awhile to
2
1684
by: Someonekicked | last post by:
hi, i cant come to find a solution for a problem in my program, I made an example of the problem; in the example i made, the problem is if happy.dat does not exist, so (!inData) will be true, and "here is the message" is sent to output to happy.dat, and if u run the program, you will see that "here is the message" is sent to happy.dat after the program ends, not be4 cout << "check"; i want that "here is the message" be sent to file be4...
0
1666
by: ruhunu Gamarala | last post by:
Hi, I get the following exception periodically. does anybody what is the reason for it to throw this exception? I really appriciate if anyone can help me on this. thanks, Chinthaka at org.postgresql.PG_Stream.flush(PG_Stream.java:356) at org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:159) at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:70)
1
3801
by: Daniel | last post by:
System.IO.StreamWriter Close or Flush method to shut down the computer in such a way that just part of the file is written? or an empty file is written? Also if the Close or Flush is to a streamwriter writing to a network share, is it possible for the network to go down in such a way that the tartet file is only partialy written? or are there some kind of check sums to prevent this.
3
22465
by: guy | last post by:
I can't find this in the documentation so I'm asking it here: I assume that if I call Close() on a Stream based class that Flush() does not need to be called before as it is implicitly called by Close()? Thanks
1
1698
by: Tom | last post by:
Do I really need to flush a streamwriter? It appears to work either way. Dim sw As StreamWriter Dim strFullPath As String = "C:\Temp\Test.txt" If File.Exists(strFullPath) Then sw = File.AppendText(strFullPath) Else sw = File.CreateText(strFullPath) End If
1
3427
by: r0main | last post by:
Hi, I'm facing an issue to send data throught the HttpWebRequest processing, I'm using the Method POST with a multipart form/data. While writing a file, my application is buffering the whole size of the file, and it sends it... That's pretty sucks with large file. while ((bytesWritten = fileStream.Read(b, 0, 4096)) 0) {
6
17224
by: tegdim | last post by:
Hello, I'm trying to send a string to a subprocesses' output stream in my java program. I'm writing the data to the stream and then trying to flush the stream. This, however , isn't actually sending anything to the subprocess (a python program) and the data only actually gets sent to the outputstream when I close the stream. I'm wanting to keep sending data to the subprocess so the writing and flushing is in a loop, but because I have to...
5
1910
by: =?Utf-8?B?cmF1bGF2aQ==?= | last post by:
(a little more info) after flushing the line (instead of closing streamwirter) it takes some x time to flush the line so, when I read from the file I cannot find the last written line. if I close the streamwriter it does find the line always. but , my next write fails "Cannot write to a closed TextWriter"
0
8703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8623
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9185
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9050
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8935
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7773
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5879
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.