GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 01-Aug-2006, 18:55
bharat suthar bharat suthar is offline
New Member
 
Join Date: May 2006
Posts: 2
bharat suthar is on a distinguished road

about file handling


i have two programmes . In one programe i m generatin some numbers and sending to a file named "output1" ,and by another programe i want to use the numbers . so i m using fstream..I want to run both the programmes simontaneosly means while the 1st one is generating numbers and sending to file ... i want that 2nd programme use them and wait for the another number which is going to be add in the file output1..... BUT here a problem the 2nd programme is not taking the all values from the file...it takes just the values which is there in the file when the 2nd programme started running ......... means it is not taking the upcoming values which are coming in the programme continuously ......so please sugeest me what to do ...........

my first programme is which is generating numbers in a file named output1

CPP / C++ / C Code:
#include<iostream.h>
#include<fstream.h>
using namespace std;
int main()
{
fstream  fout ( "output1" , ios ::app );
for (int i=0;i>-1;i++)
{
fout<< i<<endl;
for ( int j = 0 ; j < 100000000 ; j++ ) ;//just for wait little bit 
}
return 0;
}

and the 2nd programme is which is suppose to be take all the upcoming values in output1

CPP / C++ / C Code:
#include<iostream.h>
#include<fstream.h>
int main()
{
int i;	
while(1)
{  ifstream  fin("pr",ios::in);
   fin>>i;
   cout<<i<<endl;  }
return 0;}

thanks in advance
Last edited by LuciWiz : 01-Aug-2006 at 18:59. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 02-Aug-2006, 00:10
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,243
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: about file handling


First off, I assume you've read the Guidelines as requested previously. You might want to review them before posting to get the code tags right. Then it will be helpful down the road if you'd format your code better. Here are some ideas.

What you are attempting to do is extrememly difficult at best. And the way you are doing it won't work. The operating system is not going to process the files the way you want.

Is there a reason at this point in your learning you need two programs to communicate with each other? Or are you simply trying out something new? If you're just trying something out, I'd recommend shelving this idea until later when you have a better grasp of C++, files, and the operating system.

If it's something you need, work up a 'design' that explains how the two programs need to interact and we can work out a procedure that may work for your project. I'm assuming here the code you posted would be an attempt to just figure out how the communication would work to be added to a larger project.
__________________

Age is unimportant -- except in cheese
 
 

Recent GIDBlogHalfway done! by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 07:44
Download files in c for windows operating system oozsakarya C Programming Language 5 20-Jun-2006 03:33
File handling in C trinath C Programming Language 2 09-Jan-2006 12:25
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 10:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 11:28

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 05:41.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.