Lvalue required error

This is a discussion on Lvalue required error within the C Programming forums, part of the General Programming Boards category; when do we get an lvalue required error and an rvalue required error....

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    30

    Lvalue required error

    when do we get an lvalue required error and an rvalue required error.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    When you're damn unlucky!

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    395
    if you try 5=5 you get an 'invalid lvalue in assignment'-like error, is it what you mean? it happens when the left side of an assignement is not...assignable (i.e. a variable).
    I don't see any situation in which you would get the equivalent for an rvalue, as it would rather result in a syntax error...
    What was the point of the question? any context?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    A (modifiable) lvalue is required for assignment. If you have this = that; then this has to be an lvalue. There are no such things as rvalues in C, although sometimes people use it to mean "something that could be on the right-hand side of a assignment".

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    30
    Quote Originally Posted by root4 View Post
    if you try 5=5 you get an 'invalid lvalue in assignment'-like error, is it what you mean? it happens when the left side of an assignement is not...assignable (i.e. a variable).
    I don't see any situation in which you would get the equivalent for an rvalue, as it would rather result in a syntax error...
    What was the point of the question? any context?
    Code:
    int a[]={1,5,6,8};
    for(int j=0;j<5;j++)
    {
       printf("%d",*a);
        a++;
    }
    gives this error,ny idea why?

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by eklavya8 View Post
    Code:
    int a[]={1,5,6,8};
    for(int j=0;j<5;j++)
    {
       printf("%d",*a);
        a++;
    }
    gives this error,ny idea why?
    Because a++ is amazingly illegal. a is an array -- you can't move where it lives in memory.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  3. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 11:17 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21