Pipe function Conversion from Unix Platform 2 VC++

Hello friends i am trying to develop a code in Visual C. I want to convert the program from Unix platform to the Windows Platform

To display the PGM files the code in Unix Platform is this :

#include <string.h>
#include “unistd.h”
#include <stdio.h>
#include <math.h>

void DisplayPGM(unsigned char *im, int x, int y, char *title)
{
char t[30];
int pid, pfd[2];

if(pipe(pfd) == -1) printf(“pipe”);
if((pid = fork()) == -1) printf(“fork”);
else if (pid == 0)
{
if(close(0) == -1) printf(“close”);
if(dup(pfd[0]) != 0) printf(“dup”);
if(close(pfd[0]) == -1 || close(pfd[1]) == -1) printf(“close2”);
execlp(“/usr/local/bin/xv”,“xv”,“-”,“-name”,title, NULL);
}
if(close(pfd[0]) == -1) printf(“close3”);
sprintf(t,“P5\n %d %d\n 255\n”, x, y);
if(write(pfd[1],t,strlen(t)) == -1) printf(“write1”);
if(write(pfd[1],im,x*y) == -1) printf(“write2”);
if(close(pfd[1]) == -1) printf(“close4”);
}

Is there any header file or alternate code which i can use on the Visual C platform to execute this. As pipe and fork doesn’t work on the Visual C platform

Thanks

Anuj

I think you’re quite OT, anyway you shouldn’t use pipe/fork on VC, as Win32 Api has different calls for process/threads management.

If you need to get a cross platform thread handling code, I would suggest you to use Qt library (4.2 or 4.3 version, available for both Windows and Linux, if you use C++) or there are available plenty of opensource codes for your needings.

Have a look on sourceforge for “thread” keyword and good luck!