variable - modifiable lvalue

Discussion in 'C Programming' started by v4vijayakumar, May 15, 2006.

  1. What is the difference between a variable and a modifiable lvalue?
    TIA.
     
    v4vijayakumar, May 15, 2006
    #1
    1. Advertisements

  2. v4vijayakumar

    websnarf Guest

    A variable is independent named storage. An lvalue is basically just
    storage that can appear on the left side of an assignment. So in these
    cases:

    x.y = 3; /* struct { int y; } x; */
    q = "Hello"; /* char * q[]; */
    *(p + 3) = 7; /* int * p; */
    *(f(3)) = 2; /* int * f(int); */

    x.y, q, *(p+3) and *(f(3)) are all lvalues, but none are variables.
    However, x, q and p are variables. f is a function, so there is no
    variable at all involved there, nevertheless an assignment to an lvalue
    does happen.
     
    websnarf, May 15, 2006
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.