Troubles with "lvalue missing" error message 
Author Message
 Troubles with "lvalue missing" error message

I have the following in my program:

struct ctype
{
..
char unit[12];
..} *head, *current;

and then a bit later

char* input (char*);

..

char* input (char *data)
{
        return data; //basically that's all it does

Quote:
}

..

and then in another function

head->unit = input (head->unit);  //this gives me a "lvalue missing" error
every time!!!  The left side of the expression is obviously NOT missing!
Any ideas?

--
/~~~~~~~~~\ |`___________________ _______________ ___________________________

 |       |  || Boston University |_______________|___________________________|
___________ ||.................The world is coming to an end! Please log out.|
~B~l~a~c~k~ ||~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
  ~s~e~a~   ||Brevis oratio penetrat colos, longa potatio evacuat ciphos.
   ~"~"~    ||"Ya pomniu chudnoe mgnovenie     "I remember the instant
    ~"~     || kogda peredo mnoi yavilas t'y,   when you appeared to me,
     ~      || kak mimoletnoe videnie,          as an instant's vision,
~~~~~~~~~~~~`| kak genii chistoi krasotoi"      as the essence of beauty"
 ~~~~~~~~~~~~`                   Pushkin, "K***"



Sun, 21 Jul 1996 12:55:18 GMT  
 Troubles with "lvalue missing" error message

|>
|>I have the following in my program:
|>
|>struct ctype
|>{
|>..
|>char unit[12];
|>..} *head, *current;
|>
|>and then a bit later
|>
|>char* input (char*);
|>
|>..
|>
|>char* input (char *data)
|>{
|>   return data; //basically that's all it does
|>}
|>
|>..
|>
|>and then in another function
|>
|>head->unit = input (head->unit);  //this gives me a "lvalue missing" error
|>every time!!!  The left side of the expression is obviously NOT missing!
|>Any ideas?
|>

The key to your dilema is the declaration of the struct member "unit".
It's declared as an array of characters, and you are using it like a
character pointer in the failing assignment.  You will either need to
modify your data structure to use (char *) or you will need to substitute
a str[n]cpy for the assignment.

This is an example of when it doesn't pay to think of an array identifier
as a pointer. :)

Regards,
---
IBM AIX Software Services               Erik O'Shaughnessy

Austin, TX 78578                        (512) 823-9569  t/l 793-9569

Disclaimer: Opinions expressed are my own, and not IBM's. Duh.



Sun, 21 Jul 1996 16:07:13 GMT  
 Troubles with "lvalue missing" error message
Quote:

>I have the following in my program:

>struct ctype
>{
>..
>char unit[12];
>..} *head, *current;

>and then a bit later

>char* input (char*);

[ definition of input() omitted ]

Quote:
>and then in another function

>head->unit = input (head->unit);  //this gives me a "lvalue missing" error
>every time!!!  The left side of the expression is obviously NOT missing!

Right.  The type of head->unit is array of 12 char.  An array is not
an lvalue.  C doesn't have array assignment.  Maybe You want to copy
head-unit the result of input()?:
        (void) strcpy(head->unit, input(head->unit));

Dave Kristol



Sun, 21 Jul 1996 22:54:04 GMT  
 Troubles with "lvalue missing" error message

Quote:
>I have the following in my program:

>struct ctype
>{
>..
>char unit[12];
>..} *head, *current;

>..

>head->unit = input (head->unit);  //this gives me a "lvalue missing" error
>every time!!!  The left side of the expression is obviously NOT missing!
>Any ideas?

Arrays are not lvalues. Ever read K&R or the FAQ?

Dan
--
Dan Pop
CERN, CN Division

Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland



Mon, 22 Jul 1996 02:54:29 GMT  
 Troubles with "lvalue missing" error message


: " |>
: " |>I have the following in my program:
: " |>
: " |>struct ctype
: " |>{
: " |>..
: " |>char unit[12];
: " |>..} *head, *current;
: " |>
: " |>and then a bit later
: " |>
: " |>char* input (char*);
: " |>
: " |>..
: " |>
: " |>char* input (char *data)
: " |>{
: " |>  return data; //basically that's all it does
: " |>}
: " |>
: " |>..
: " |>
: " |>and then in another function
: " |>
: " |>head->unit = input (head->unit);  //this gives me a "lvalue missing" error
: " |>every time!!!  The left side of the expression is obviously NOT missing!
: " |>Any ideas?
: " |>

: " The key to your dilema is the declaration of the struct member "unit".
: " It's declared as an array of characters, and you are using it like a
: " character pointer in the failing assignment.  You will either need to
: " modify your data structure to use (char *) or you will need to substitute
: " a str[n]cpy for the assignment.

: " This is an example of when it doesn't pay to think of an array identifier
: " as a pointer. :)

Argh!!!!  My C book said that char[] and *char are the same and demonstrated
it by char[offset] == *(char+offset)  I have to rewrite a lot of the code
because of this stupid problem :(

Thanks anyways!

--
/~~~~~~~~~\ |`___________________ _______________ ___________________________

 |       |  || Boston University |_______________|___________________________|
___________ ||.................The world is coming to an end! Please log out.|
~B~l~a~c~k~ ||~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
  ~s~e~a~   ||Brevis oratio penetrat colos, longa potatio evacuat ciphos.
   ~"~"~    ||"Ya pomniu chudnoe mgnovenie     "I remember the instant
    ~"~     || kogda peredo mnoi yavilas t'y,   when you appeared to me,
     ~      || kak mimoletnoe videnie,          as an instant's vision,
~~~~~~~~~~~~`| kak genii chistoi krasotoi"      as the essence of beauty"
 ~~~~~~~~~~~~`                   Pushkin, "K***"



Mon, 22 Jul 1996 00:15:03 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Error "missing GetStartupInfoA." using wnaspi32.dll

2. Error "free"-ing "malloc"-ed memory

3. "Not a typewriter" error message

4. Q: Error message "Multiple rows updated"???

5. Error message: "Interface not registered"

6. "Cannot save file" error message

7. "Cannot save file" error message

8. "Implement Connection Point..." option is missing

9. Help: Missing dll file "msvcp60.dll"

10. "Update All Dependencies" missing

11. "Update All Dependencies" missing

 

 
Powered by phpBB® Forum Software