Interprocess communication using pipe

Hi guys

I am having problems creating a "process race" application.
The following is what I have come up with so far:

A child process

#include
#include
using namespace std;

int main (int argc, TCHAR *argv[])
{
for(long i=0;i<1000000000;i=i+10000){
cout << i;
}
return 0;
}

Main program (excerpt)

while (true)
{
for(int i=0;i<antalProcesser;i++)
{
ReadFile(hPipeLasning[i],&t,sizeof(long),&dw,NULL);
FlushFileBuffers(hPipeLasning[i]);
*&processPosition[i] = t;
}
}

where hPipeLasning is the handle to read from the pipe. Why does this solution not work, I get really weird numbers. My basic idea was that I would use cout to send numbers (long) through the pipe. In the main program I would read the number from the pipe and update a posistion variable (processPosition[i]). What am I doing wrong? Do I have to do something special in the child program?

I would appreciate some help.

Thx
David

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion