std::ostream::open takes a second argument that says what you want to do with the file you're opening. std::ios::app opens the file in 'append' mode:
std::ofstream myFile;
myFile.open( "filename.txt", std::ios::app );
You can also cause data to be written to the file by calling flush , without closing the file each time you want to write the data to disk.
ravenous
Practically a Master Poster
681 posts since Jul 2005
Reputation Points: 286
Solved Threads: 111
Skill Endorsements: 8
If there is no need to store the data for later use in the file you might do better to use a socket or named pipe. Your application can write to the one end of the pipe and the php script can read from the other end when data is available. In fact, the php script will block while reading the pipe/socket until data is available so there is no need to busy loop until that point.
L7Sqr
Practically a Posting Shark
849 posts since Feb 2011
Reputation Points: 253
Solved Threads: 155
Skill Endorsements: 7
Your code is editing data in memory, not on disk so in order for others to see the changes the data must be written to disk, and re-loaded by whomever needs it.
Windows: CreateNamedPipe
Linux: Pipes, FIFO, and IPC
L7Sqr
Practically a Posting Shark
849 posts since Feb 2011
Reputation Points: 253
Solved Threads: 155
Skill Endorsements: 7
If you are dealing with multiple machines with varying platforms you may be best just opening a network socket and communicating that way. This would serve you best if at some point you needed to support machines hosted in various locations.
L7Sqr
Practically a Posting Shark
849 posts since Feb 2011
Reputation Points: 253
Solved Threads: 155
Skill Endorsements: 7