Interprocess communication using pipes and fork

I'm very worried. I have an assignment that is due in 3 weeks, and also tute exercises which I can't seem to understand and work out.

Okay, the question:
The parent process will convert the command arguments into integer values using atoi() and store them into an integer array which you will create using malloc() ONLY and is to be a local variable declared in main(). The parent process will then send the values of the array to Process B by writing to pipe1's output stream.

My question here is when i pass it through the pipe to Process B the output is always incorrect, gives me some rubbish. The examples which I've found also always pass string thru the pipe. Can I pass the pointer of the array to Process B and ask Process B to read the input from there?

I don't know why I find this so difficult to understand and have been looking around the internet for notes or examples to ponder on, but seems like all the examples are passing strings thru pipes.

Really really appreciate any sort of help here.

What do your read() / write() calls look like?

I wrote the solution, but I don't understand how it really works.

#include <sys/types.h>
#include <unistd.h>
#define MSGSIZE 16
main(int argc, char *argv[])
{
pid_t pid;
int p1[2];
int number,i,a;
int *ip, *head;
int inbuf[MSGSIZE];
//A opens pipe
if(pipe(p1)==-1)
{
perror("main err");
exit(1);
}
//A forks B
switch(pid=fork())
{
case -1:
perror("error");
exit(2);
case 0:
close(p1[1]);
for(a=1;a<argc;a++)
{
read(p1[0], inbuf, MSGSIZE);
printf("%d", inbuf[0]);
//why must i specify inbuf[0]? why can't i just write inbuf?

		\}
		break;
	default:
		ip=\(int \*\)malloc\(10*sizeof\(int\)\);
		head=ip;
		close\(p1[0]\);

		for\(i=1;i&lt;argc;i\+\+\)
		\{			
			*ip = atoi\(argv[i]\);
			write\(p1[1], ip, MSGSIZE\);
			ip\+\+;
		\}		
		
\}

}