对C中指针的有效操作 [英] Valid operations on pointers in C

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

问题描述

为什么C中允许分区/多元化/添加指针不允许

Why division/mulitiplication/addition of pointers are not
allowed in C?

推荐答案

aruna< ar ********@yahoo.co.in>潦草地写了下面的内容:
aruna <ar********@yahoo.co.in> scribbled the following:
为什么在C中不允许分区/多指/添加指针?
Why division/mulitiplication/addition of pointers are not
allowed in C?




首先定义它是怎么回事会工作,然后我们会明白为什么它应该或

不应该被允许。


-

/ - Joona Palaste(pa*****@cc.helsinki.fi)-------------芬兰-------- \

\ - http://www.helsinki.fi/~palaste - --------------------规则! -------- /

显而易见的数学突破将是开发一种简单的方法来获得大额素数。

- 比尔盖茨



First define how it would work, and then we''ll see why it should or
should not be allowed.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"The obvious mathematical breakthrough would be development of an easy way to
factor large prime numbers."
- Bill Gates


" aruna" < AR ******** @ yahoo.co.in>在留言中写道

新闻:a2 ************************** @ posting.google.c om ...
"aruna" <ar********@yahoo.co.in> wrote in message
news:a2**************************@posting.google.c om...
为什么在C中不允许分区/多重/添加指针?
Why division/mulitiplication/addition of pointers are not
allowed in C?




这些操作没有明显的意义,所以没有必要。



Those operations have no obvious meaning, so there is no need.


-----开始PGP签名的消息-----

哈希:SHA1
< br $> b $ b aruna写道:


|为什么划分/多指/添加指针不是

|允许在C?


指针可以被认为是数据项的位置。


减去一个指针来自另一个给你两个数据项之间的''距离'。


两个指针的添加内容会给你什么? (提示:''橡树巷'''到'757 Main Street West'的'

'给你什么?'


什么会两个指针的乘法给你? (提示:''12 Oak Lane''与''757 Main Street West''相加的是什么?$

什么会两个指针的划分给你? (提示:''橡树巷'''到'757 Main Street West'的

分区是什么给你的?)


而指针减法是有意义的,其他操作则没有。


- -

Lew Pitcher,IT顾问,企业应用程序架构

企业技术解决方案,道明银行金融集团


(这里表达的意见是我自己的,不是我的雇主的)

--- --BEGIN PGP SIGNATURE -----

版本:GnuPG v1.2.4(MingW32)

iD8DBQFAiSyFagVFX4UWr64RAo1XAKC8YTdVBF0bWGf93dNiVV zWrhMhsQCeOszA

RKCqbpu4N77 + X + 8EE5VcwEk =

= + jwy

----- END PGP SIGNATURE -----
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

aruna wrote:

| Why division/mulitiplication/addition of pointers are not
| allowed in C?

A pointer can be considered to be the ''location'' of a data item.

Subtraction of one pointer from another gives you the ''distance'' between
two data items.

What would addition of two pointers give you? (Hint: What does the
addition of ''12 Oak Lane'' to ''757 Main Street West'' give you?)

What would multiplication of two pointers give you? (Hint: What does the
multiplication of ''12 Oak Lane'' with ''757 Main Street West'' give you?)

What would division of two pointers give you? (Hint: What does the
division of ''12 Oak Lane'' by ''757 Main Street West'' give you?)

While pointer subtraction is meaningful, the other operations are not.

- --

Lew Pitcher, IT Consultant, Enterprise Application Architecture
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer''s)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFAiSyFagVFX4UWr64RAo1XAKC8YTdVBF0bWGf93dNiVV zWrhMhsQCeOszA
RKCqbpu4N77+X+8EE5VcwEk=
=+jwy
-----END PGP SIGNATURE-----


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

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