C语言中变量和数据对象之间的区别? [英] Difference between variable and data object in C language?
问题描述
我正在阅读C Primer Plus,遇到了我不理解的以下内容-
I was reading C Primer Plus and came across the following lines that I couldn't understand-
指针?这些是什么?基本上,指针是一个变量(或者,更多 通常,一个数据对象)的值是一个内存地址.
Pointers? What are they? Basically, a pointer is a variable (or, more generally, a data object)whose value is a memory address.
仅供参考,我之前遇到过这些问题-
Just for reference,I came across these lines earlier-
考虑分配声明.其目的是将值存储在 内存位置.数据对象是数据区域的通用术语 可用于保存值的存储. C标准仅使用 这个概念的术语对象.识别对象的一种方法是 使用变量名.
Consider an assignment statement. Its purpose is to store a value at a memory location. Data object is a general term for a region of data storage that can be used to hold values. The C standard uses just the term object for this concept. One way to identify an object is by using the name of a variable.
我尝试了Google搜索,但找不到任何东西.这些基本术语使我感到困惑,因此请帮助我理解这些术语.
I tried googleing but couldn't find anything.These basic terminologies are confusing me so please help me understand these terms.
推荐答案
数据对象是存储程序使用的信息的内存位置.
A data object is a memory location that stores information used by the program.
变量是程序中用于引用数据对象的名称.
A variable is a name used in the program to refer to a data object.
所以,如果您写:
int a;
它告诉编译器创建一个可以容纳整数的数据对象,并且在程序中您可以使用名称a
来访问该数据对象.
it tells the compiler to create a data object that can hold an integer, and in the program you can use the name a
to access that data object.
指针是一个数据对象,其值是某些其他数据对象在内存中的位置.因此,如果您这样做:
A pointer is a data object whose value is the location in memory of some other data object. So if you do:
int *pa = &a;
您正在创建一个变量pa
,该变量引用一个数据对象,其内容是根据a
变量声明创建的数据对象的地址.
you're creating a variable pa
that refers to a data object whose contents are the address of the data object created as a result of the a
variable declaration.
这篇关于C语言中变量和数据对象之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!