fbpx
维基百科

解引用运算符

解引用运算符(dereference operator)或称间址运算符(indirection operator)。[1]C语言编程语言家族中常表示为"*" (一个星号),为单元运算符,作用于1个指针变量,返回该指针地址的等效左值。这被称为指针的解引用。例如:

 int x;  int *p; // * is used in the declaration:  // p is a pointer to an integer, since (after dereferencing),  // *p is an integer  x = 0;  // now x == 0  p = &x; // & takes the address of x  // now *p == 0, since p == &x and therefore *p == x  *p = 1; // equivalent to x = 1, since p == &x  // now *p == 1 and x == 1 

在C语言中,&是解引用运算符*的逆运算。因此*&s等价于s。例如:

 p = &s; // the address of s has been assigned to p; p == &s;  // *p is equivalent to s 

结构s的成员a的值可表示为s.a。若指针p指向s (即p == &s), s.a等价于(*p).a,也可用结构解引用运算符作为语法糖缩写表示为p->a

 p = &s; // the address of s has been assigned to p; p == &s;  // s.a is equivalent to (*p).a  // s.a is equivalent to p->a  // (*p).a is equivalent to p->a 

Unix的外壳脚本以及一些工具软件如Makefile中,美元符"$"为解引用运算符,用于把变量名字转译为其内容。

参见 编辑

参考文献 编辑

  1. ^ . [2022-03-04]. (原始内容存档于2022-07-09). 

解引用运算符, 此條目或其章節极大或完全地依赖于某个单一的来源, 2022年3月5日, 请协助補充多方面可靠来源以改善这篇条目, 致使用者, 请搜索一下条目的标题, 来源搜索, 网页, 新闻, 书籍, 学术, 图像, 以检查网络上是否存在该主题的更多可靠来源, 判定指引, dereference, operator, 或称间址运算符, indirection, operator, c语言编程语言家族中常表示为, 一个星号, 为单元运算符, 作用于1个指针变量, 返回该指针地址的等效, href, html, cla. 此條目或其章節极大或完全地依赖于某个单一的来源 2022年3月5日 请协助補充多方面可靠来源以改善这篇条目 致使用者 请搜索一下条目的标题 来源搜索 解引用运算符 网页 新闻 书籍 学术 图像 以检查网络上是否存在该主题的更多可靠来源 判定指引 解引用运算符 dereference operator 或称间址运算符 indirection operator 1 C语言编程语言家族中常表示为 一个星号 为单元运算符 作用于1个指针变量 返回该指针地址的等效 a href E5 B7 A6 E5 80 BC html class mw redirect title 左值 左值 a 这被称为指针的解引用 例如 int x int p is used in the declaration p is a pointer to an integer since after dereferencing p is an integer x 0 now x 0 p amp x amp takes the address of x now p 0 since p amp x and therefore p x p 1 equivalent to x 1 since p amp x now p 1 and x 1 在C语言中 amp 是解引用运算符 的逆运算 因此 amp s等价于s 例如 p amp s the address of s has been assigned to p p amp s p is equivalent to s 结构s的成员a的值可表示为s a 若指针p指向s 即p amp s s a等价于 p a 也可用结构解引用运算符作为语法糖缩写表示为p gt a p amp s the address of s has been assigned to p p amp s s a is equivalent to p a s a is equivalent to p gt a p a is equivalent to p gt a Unix的外壳脚本以及一些工具软件如Makefile中 美元符 为解引用运算符 用于把变量名字转译为其内容 参见 编辑结构解引用运算符参考文献 编辑 Pointer related operators C reference source MSDN 2022 03 04 原始内容存档于2022 07 09 取自 https zh wikipedia org w index php title 解引用运算符 amp oldid 72812691, 维基百科,wiki,书籍,书籍,图书馆,

文章

,阅读,下载,免费,免费下载,mp3,视频,mp4,3gp, jpg,jpeg,gif,png,图片,音乐,歌曲,电影,书籍,游戏,游戏。