c - *p 是左值还是右值

标签 c lvalue rvalue

下面的代码中,*a是右值还是左值?

#include <stdio.h>

void main()
{
    int b=2;
    int *a=NULL;
    a=&b;
    *a=3;
    printf("%d",*a);

}

最佳答案

正如 http://en.wikipedia.org/wiki/Value_%28computer_science%29 中所公开的:

Lvalues have memory addresses that are programmatically accessible to the running program (e.g., via some address-of–operator like "&" in C/C++), meaning that they are variables or dereferenced references to a certain memory location. Rvalues can be lvalues (see below) or non-lvalues

所以,*a 是左值

关于c - *p 是左值还是右值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17684476/

相关文章:

c++ - std::move 未明确使用时,c++11 何时会自动执行 move ?

c++ - 为什么右值引用绑定(bind)到 xvalue 在我的代码中不起作用?

C编程;需要左值

c++ - 默认情况下函数返回值是常量(右值)吗?

c++ - 有没有办法正确地 std::move const 数据?

c++ - 如何在 C/C++ 中使用 SSHA1?

c - C 中的套接字和线程

c - 将包含动态数组的结构写入二进制文件 (C)

c++ - C++中的类型转换和引用

c - 处理大量字符串常量