Thread: Reading/writing to the same file with multiple programs

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    1

    Reading/writing to the same file with multiple programs

    So I am working on a project where I am using C++ and Adobe Flash to preform a simple simulation in C++ and display the results using Flash in real-time.

    I have not actually started the project yet so I am looking for some guidance on where to begin. My current idea for integrating the 2 programs is to have a .txt file that the C++ program will continually write to and change and then the flash program will read from file and display the results of the simulation accordingly.

    My question is is it possible to have 2 programs accessing the same file continuously like this? Or is there a better way to share information between the 2 programs?

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    30
    It is possible. Open it in binary random access mode, with shared access possible. I'd imagine that using windows' message queues would be easier, but I don't know if flash programs have the capability of manipulating its own message queue.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    If you need process inter-communication, I'd suggest the use of shared memory and windows messages, because it's way faster than dumping data to the hard drive (and fairer to the user, too).
    Shared memory can be shared among processes, so both processes can read and write that data. And the windows messages can be used for communication, so you can notify your renderer that there is data available, for example.


    EDIT:
    I don't know if Flash supports this kind of stuff. Perhaps you should look into if Flash supports some kind of process communication.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File Writing Problem
    By polskash in forum C Programming
    Replies: 3
    Last Post: 02-13-2009, 10:47 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM