Consider the following code:
writer.c
mkfifo(\"/tmp/myfifo\", 0660);
int fd = open(\"/tmp/myfifo\", O_WRONLY);
char *foo, *bar;
...
write(fd, foo
To generalize WhirlWind's answer slightly, you've got to establish a protocol of SOME variety. There has to be order to what you are sending or else you don't know top from bottom, as you point out.
Both of WhirlWind's suggestions will work. You can also go so far as to implement a custom (or standard) protocol on top of a pipe or FIFO to make porting your code to a more distributed environment with disparate systems and easier task later. The crux of the issue, though, is that you've got to set RULES for communicating before you're able to actually communicate.