如果不是内存地址,C 指针究竟是什么? [英] What exactly is a C pointer if not a memory address?

查看:18
本文介绍了如果不是内存地址,C 指针究竟是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在有关 C 的知名来源中,在讨论了 & 运算符后给出了以下信息:

In a reputable source about C, the following information is given after discussing the & operator:

... 术语[address of] 保留下来有点遗憾,因为它混淆了那些不知道地址是什么的人,并误导了那些知道地址的人:将指针视为如果他们是地址通常会导致悲伤......

... It's a bit unfortunate that the terminology [address of] remains, because it confuses those who don't know what addresses are about, and misleads those who do: thinking about pointers as if they were addresses usually leads to grief...

我读过的其他材料(我会说,来自同样有信誉的来源)总是毫不掩饰地将指针和 & 运算符称为提供内存地址.我很想继续寻找事情的真相,但是当有信誉的消息来源有点不同意时,这有点困难.

Other materials I have read (from equally reputable sources, I would say) have always unabashedly referred to pointers and the & operator as giving memory addresses. I would love to keep searching for the actuality of the matter, but it is kind of difficult when reputable sources KIND OF disagree.

现在我有点困惑——究竟是指针,那么,如果不是内存地址呢?

Now I am slightly confused--what exactly is a pointer, then, if not a memory address?

附言

作者后来说:...不过我会继续使用address of"这个词,因为发明一个不同的 [词] 会更糟.em>

The author later says: ...I will continue to use the term 'address of' though, because to invent a different one [term] would be even worse.

推荐答案

C 标准没有定义指针在内部是什么以及它在内部如何工作.这是有意为之,以免限制平台数量,其中 C 可以作为编译或解释语言来实现.

The C standard does not define what a pointer is internally and how it works internally. This is intentional so as not to limit the number of platforms, where C can be implemented as a compiled or interpreted language.

指针值可以是某种 ID 或句柄或几个 ID 的组合(对 x86 段和偏移量说你好),不一定是真正的内存地址.此 ID 可以是任何内容,甚至是固定大小的文本字符串.非地址表示对于 C 解释器可能特别有用.

A pointer value can be some kind of ID or handle or a combination of several IDs (say hello to x86 segments and offsets) and not necessarily a real memory address. This ID could be anything, even a fixed-size text string. Non-address representations may be especially useful for a C interpreter.

这篇关于如果不是内存地址,C 指针究竟是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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