Connecting Tech Pros Worldwide Forums | Help | Site Map

error: invalid lvalue in assignment

Newbie
 
Join Date: Mar 2008
Posts: 1
#1: Mar 16 '08
Hi,

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

Expand|Select|Wrap|Line Numbers
  1. pthread_t msg_receive(char *sbuffer, int *maxlen) {
  2.     // get the values for sbuffer and maxlen
  3.  
  4.     strcpy(sbuffer, current->message);
  5.     &maxlen = current->messagelen;      // invalid lvalue here
  6. }
  7.  
current is a struct ptr with these attributes:
Expand|Select|Wrap|Line Numbers
  1. current {
  2.     char *message;
  3.     int messagelen;
  4.     char *replymsg;
  5.     int replylen;
  6. }
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.

Ganon11's Avatar
Moderator
 
Join Date: Oct 2006
Location: New York, United States of America
Posts: 3,428
#2: Mar 17 '08

re: error: invalid lvalue in assignment


Expand|Select|Wrap|Line Numbers
  1. &maxlen
& 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:

Expand|Select|Wrap|Line Numbers
  1. *maxlen
Reply