#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
struct msg {
int pid;
int giffs;
int curr;
};
main()
{
struct msg send = {1, 2, 3};
int p[2], pid, i;
int *inbuff;
char *q;
pipe(p);
pid= fork();
if(pid > 0) {
write(p[1], (char *)&send, sizeof(send));
printf("%ld \n", sizeof(send));
sleep(1);
} else {
read(p[0],(char *) inbuff, sizeof(send));
for (i=0;i<sizeof(send)/sizeof(int);i++){
printf("%d\n", *inbuff++);
}
}
}
try this code.......... here make sure you use waitpid() instead of sleep so that parent process waits for child procees to terminate or else you will get inappropriate response...........