error: invalid lvalue in assignment

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yyhkitty
    New Member
    • Mar 2008
    • 1

    error: invalid lvalue in assignment

    Hi,

    I keep getting two invalid lvalue in assignment errors. here's what my code looks like:

    [code=c]pthread_t msg_receive(cha r *sbuffer, int *maxlen) {
    // get the values for sbuffer and maxlen

    strcpy(sbuffer, current->message);
    &maxlen = current->messagelen; // invalid lvalue here
    }
    [/code]
    current is a struct ptr with these attributes:
    [code=c]current {
    char *message;
    int messagelen;
    char *replymsg;
    int replylen;
    }[/code]

    the other place i'm getting the lvalue error is basically the same. me trying to deference an int to assign it a value from a struct.

    I'd really appreciate if someone can tell me what i've done wrong.

    thanks.
    Last edited by Ganon11; Mar 17 '08, 12:07 AM. Reason: Please use the [CODE] tags provided.
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    [code=c]&maxlen[/code]

    & is not the de-reference operator, it's the address-of operator. You're using it to find the address of the pointer to an integer. You should be using *, like so:

    [code=c]*maxlen[/code]

    Comment

    Working...