码迷,mamicode.com
首页 > 其他好文 > 详细

指针左值错误

时间:2020-06-15 11:58:51      阅读:48      评论:0      收藏:0      [点我收藏+]

标签:+=   amp   val   The   potential   assign   左值   his   after   

1
2 int main(void)
3 {
4 int a=1;
5 char *pp;
6 void *p=&a;
7 p++;
8 p+=a;
9 pp=(char *)p;
10 pp+=a;
11 //(char *)p +=a;
12 }

 

(char *)p +=a; 会报左值错误

The result of (int *) p is a value. This is different from an lvalue. An lvalue (potentially) designates an object. For example, after int x = 3;, the name x designates the object that we defined. We can use it in an expression generally, such as y = 2*x, and then the x is used for its value. But we can also use it in an assignment, such as x = 5, and then the x is used for the object.

 

指针左值错误

标签:+=   amp   val   The   potential   assign   左值   his   after   

原文地址:https://www.cnblogs.com/idyllcheung/p/13129949.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!