Author |
Message |
isaiahk9
![](http://compsci.ca/v3/uploads/user_avatars/1465120414488e669e1f83a.jpg)
|
Posted: 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? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
USEC_OFFICER
![](http://compsci.ca/v3/uploads/user_avatars/16624966004bb548179e82e.png)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
isaiahk9
![](http://compsci.ca/v3/uploads/user_avatars/1465120414488e669e1f83a.jpg)
|
Posted: 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? |
|
|
|
|
![](images/spacer.gif) |
BigBear
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
isaiahk9
![](http://compsci.ca/v3/uploads/user_avatars/1465120414488e669e1f83a.jpg)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Dan
![](http://wiki.compsci.ca/images/archive/3/3c/20100325043407!Danspic.gif)
|
Posted: 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! |
|
|
|
![](images/spacer.gif) |
isaiahk9
![](http://compsci.ca/v3/uploads/user_avatars/1465120414488e669e1f83a.jpg)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
|