
double char pointer question
I'm trying to make a program that allows processes to send and receive
from mailboxes, and I'm getting a little confused with something. The
signature for the receive function is:
int receive(int mailbox, char ** a_message)
So that a process can specify the mailbox it wants to read from and read
the message in that mailbox into a_message. The signature was given to us
by our prof, but I don't understand why it's a double char pointer,
instead just char * a_message enough? My questions are, if someone wants
to use this function, how would they call it, and how is a_message used
within the function definition.
Example:
If this variable is declared for the message to be read into:
char * buffer;
is this how the function should be called?
receive (1, &buffer);
Also, within the function, how do you use the a_message variable. So if
you want to store message_from_mailbox in the variable a_message, would it
be done like this:
*a_message = message_from_mailbox;
OR a_message = &message_from_mailbox;
Any help would be greatly appreciated. Once I know how this works, I can
finish off the rest of my assignment easily (I hope)
Thanks!
Madeeha