与指针C添加行为 [英] C behavior with pointer addition

查看:134
本文介绍了与指针C添加行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设:

int a[N];
int *p; 

为什么 AP 工作,并能 A + P 不与错误:无效的操作数为二进制+。

why does a-p work yet a+p does not with error: "invalid operands to binary +".

推荐答案

区别的两个指针之间是有意义的,也就是说,它是两个指针之间的元素(提供的数量,它们都位于内在同一阵列)。

The difference between two pointers is meaningful, i.e. it is the number of elements between the two pointers (provided that they both lie within the same array).

添加的两个指针是没有意义的,但(你会如何跨preT吗?)。

Adding two pointers makes no sense though (how would you interpret it ?).

这篇关于与指针C添加行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆