double char pointer question 
Author Message
 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



Tue, 28 Aug 2001 03:00:00 GMT  
 double char pointer question
Your questions are way too general. Please post your code and ask more
specific questions
--

Paul Lutus
www.arachnoid.com

Quote:

>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



Tue, 28 Aug 2001 03:00:00 GMT  
 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)

My best guess. It uses char** because the message you receive from mailbox
is probably a set of strings. char** can represent a 2-dimensional array of
strings. For example, one line of your message from mailbox is one string
which is char*. and many lines are thus the whole message. Hope this helps.
-sk



Wed, 29 Aug 2001 03:00:00 GMT  
 double char pointer question


Quote:


> : 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)

> My best guess. It uses char** because the message you receive from mailbox
> is probably a set of strings. char** can represent a 2-dimensional array of
> strings. For example, one line of your message from mailbox is one string
> which is char*. and many lines are thus the whole message. Hope this helps.

Or, receive() is supposed to *supply* the memory for the "message",
either allocating it or passing on memory supplied by the caller
to send(), passing back a pointer the caller dereferences.  

- David.Thompson at but not for trintech.com



Fri, 31 Aug 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Reg.allocating memory for double char pointer(char ** buf)

2. A char pointer (char *) vs. char array question

3. Comparison with pointer to pointer to char, and char

4. double pointer (or pointer to pointer)

5. QueryInterface basic question-- why the double pointer?

6. QueryInterface basic question-- why the double pointer?

7. pointer to char and heap (i forgot a question)

8. question about array of pointers to chars

9. pointer to char question

10. Pointer to char question

11. More Pointer To Char Question?

12. A question about passing a char pointer...

 

 
Powered by phpBB® Forum Software