I am using ofstream() to write data into file, i want the program to perform such a way that it should be keep on writting the string into the file as soon as the value gets assingned to string variable, and it should be writting before calling the close().
The need is,
I am getting the keystrokes of the keyboard, and i want it to be stored it in to the file… so when ever a key is pressed i want it to be written into the file……..
can anyone help me to do that in c++………
Call
flush()on the ofstream after writing to it. That will cause the output to be actually written instead of being buffered.