gpt4 book ai didi

c - 为什么 C 使用星号来声明指针,而不是像 Pascal 那样使用插入符号?

转载 作者:行者123 更新时间:2023-11-30 20:50:11 27 4
gpt4 key购买 nike

两种语言都有相似的起源,所以我想知道这种差异从何而来。

最佳答案

答案是因为B使用*来声明指针。这是维基百科中关于 development of C 的一行内容。 :

However B's inability to take advantage of some of the PDP-11's features, notably byte addressability, led to C. The name of C was chosen simply as the next after B.

这是B中的用法:

In the original language it was spelled rv, and later !, while B uses the unary *. Thus, if p is a cell containing the index of (or address of), or pointer to) another cell, *p refers to the contents of the pointed-to cell, either as a value in an expression or as the target of an assignment.

C 是基于 B 的,用 B 编写的程序对于 C 程序员来说是相当容易理解的;因为 B 本质上是 C 的简单版本。B 和 C 之间最显着的区别是 B 是无类型语言,即变量没有字符或整数等显式数据类型。或者更确切地说,只有一种数据类型:机器字,相当于 C 的整数类型“int”。

以下是维基百科中 C 和 Pascal 起源的区别:

Both are descendants of the ALGOL language series.Pascal stems directly from ALGOL W, while it shared some new ideas with ALGOL 68. The C language is more indirectly related to ALGOL, originally through B, BCPL, and CPL, and later through ALGOL 68.

所以,origin of C and Pascal 是有区别的,不管你说什么。

关于c - 为什么 C 使用星号来声明指针,而不是像 Pascal 那样使用插入符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49766963/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com