often used seldom defined terms: lvalue

后端 未结 8 1801
南旧
南旧 2020-11-27 17:25

What is an lvalue?

8条回答
  •  甜味超标
    2020-11-27 18:01

    An lvalue is a value that can be assigned to:

    lvalue = rvalue;
    

    It's short for "left value" or "lefthand value" and it's basically just the value on the left of the = sign, i.e. the value you assign something to.

    As an example of what is not an lvalue (i.e rvalue only):

    printf("Hello, world!\n") = 100; // WTF?
    

    That code doesn't work because printf() (a function that returns an int) cannot be an lvalue, only an rvalue.

提交回复
热议问题