Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Two programs reading/writing to the same file at one - possible?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
isaiahk9




PostPosted: Tue Apr 13, 2010 5:48 pm   Post subject: Two programs reading/writing to the same file at one - possible?

Quick question. My friend is currently making an eDragon (a screen-mate, similar to eSheep), and I am currently making an eKratos (as in Kratos from God of War). However, I would like them to interact: if I turned on my eKratos program while his eDragon program was on (on the same computer), then maybe they would fight.

I believe the easiest way to do this would be to have each program write to their own text files integers representing their current state. Then the other program would read the original program's text files, thus allowing information to be exchanged between the two programs.

One question therefore: Can two Turing programs read/edit the same text file at once?
Sponsor
Sponsor
Sponsor
sponsor
USEC_OFFICER




PostPosted: Tue Apr 13, 2010 7:02 pm   Post subject: RE:Two programs reading/writing to the same file at one - possible?

Maybe, but I'm sure not at the same time.
isaiahk9




PostPosted: Tue Apr 13, 2010 7:16 pm   Post subject: RE:Two programs reading/writing to the same file at one - possible?

Hmm, that's what I'm really wondering about.
I suppose I could have the programs do some funny synchronized opening and closing of files, but that would be a major pain.

Does anybody know whether more than one program could read/write to a file at a time?
BigBear




PostPosted: Tue Apr 13, 2010 7:44 pm   Post subject: RE:Two programs reading/writing to the same file at one - possible?

not at the exact same time. why not have two one that it reads from and one that it writes to
isaiahk9




PostPosted: Tue Apr 13, 2010 7:50 pm   Post subject: RE:Two programs reading/writing to the same file at one - possible?

Dang. I guess what I'll do is I'll make the programs make synchronized switches between the text files then. Thanks for the help and advice though.
Dan




PostPosted: Tue Apr 13, 2010 7:52 pm   Post subject: RE:Two programs reading/writing to the same file at one - possible?

http://en.wikipedia.org/wiki/File_locking
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
isaiahk9




PostPosted: Tue Apr 13, 2010 8:02 pm   Post subject: RE:Two programs reading/writing to the same file at one - possible?

Thanks Hacker Dan. The background should help with the synchronization.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: