C语言 c中指针的数据类型是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3976326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 06:44:43  来源:igfitidea点击:

What is the datatype of pointer in c?

cpointers

提问by user384636

are pointers of integer or unsigned datatype?

是整数指针还是无符号数据类型?

回答by Ignacio Vazquez-Abrams

No. They're pointers, whose size is system-dependent and whose only compatible type is void*.

不。它们是指针,其大小取决于系统,唯一兼容的类型是void*.

回答by John Bode

Pointers are of pointer type. If you're asking about how pointer values are represented in memory, that really depends on the platform. They may be simple integral values (as in a flat memory model), or they may be structured values like a page number and an offset (for a segmented model), or they may be something else entirely.

指针是指针类型。如果您问的是指针值如何在内存中表示,那实际上取决于平台。它们可能是简单的整数值(如在平面内存模型中),或者它们可能是结构化值,如页码和偏移量(对于分段模型),或者它们可能完全是别的东西。

回答by Niraj Sangroula

In C, pointer can access the variables of any data types. The pointer should be declared with the data type of the variable the pointer will be pointing. To print the address of the pointer in hexadecimal format use %pand to print the address in other forms use %u.If the pointer is going to be used to display value of pointing variable, use *pointer_nameand just for address use pointer_name.

在 C 中,指针可以访问任何数据类型的变量。应该使用指针将指向的变量的数据类型声明指针。要以十六进制格式%p打印指针的地址使用,并以其他形式打印地址使用%u。如果指针将用于显示指向变量的值,请使用*pointer_name和 仅用于地址使用pointer_name

回答by SANKET RAHANE

int *p;

国际*p;

data type of *p is pointer. And it points to integer type variable. It stores address in hexadecimal format.

*p 的数据类型是指针。它指向整数类型变量。它以十六进制格式存储地址。

回答by Mahesh

Pointers to any datatype either it may be of char/int/float/double/... are unsigned integers only.

指向任何数据类型的指针,它可能是 char/int/float/double/... 只是无符号整数。

Reason: Since a pointer stores the address, which is a location in computer memory, it's always positive,can't be negative.

原因:由于指针存储地址,它是计算机内存中的一个位置,因此它始终为正,不能为负。

回答by user2606242

What is the data type of pointer in C? is the unique question.

C中指针的数据类型是什么?是独特的问题。

One should not deviate from the question to give any kind of explanation on pointers as the answwer to the question?

一个人不应该偏离问题对指针进行任何形式的解释作为问题的答案?

Answer.

回答。

  1. What is the data type name of a set of intergers in C? The name is int , which is the name of the set comprising of all the permissible integers. Hence we declare int x; where x can assume any value from the set.

  2. Similarly , What is name of the set of all the permissible addresses or pointers? .The set name can only be the character '*' as I fathom, though no explanation is seen anywhere in C language narratives.

  1. C中一组整数的数据类型名称是什么?名称是 int ,它是由所有允许的整数组成的集合的名称。因此我们声明 int x; 其中 x 可以采用集合中的任何值。

  2. 同样,所有允许的地址或指针的集合的名称是什么?.集合名称只能是我理解的字符“*”,尽管在C语言叙述中没有任何解释。

Hence we declare the pointer variable as *x; where * is the data type name. Otherwise why should a pointer data type is thought about and brought under the user defined data type. Since there are all the RAM cells, the '*' data type forms a subset of permissible and accebile memory cells. Hence this is a data type name of a set of pointers.

因此我们将指针变量声明为 *x; 其中 * 是数据类型名称。否则为什么要考虑指针数据类型并将其归入用户定义的数据类型。由于存在所有 RAM 单元,“*”数据类型构成了允许和可访问的存储单元的子集。因此,这是一组指针的数据类型名称。

The int is the modifier as in signed char c; where signed is the modifier in C.Hence we may have int *x; to mean that data in the location is an integer which is a necessary information for the compiler.

int 是在 signed char c 中的修饰符;其中 signed 是 C 中的修饰符。因此我们可能有 int *x; 意味着该位置中的数据是一个整数,这是编译器的必要信息。

C speaks about pointer data type as the user data type. Perhaps it is wrong to consider the pointer data type as the user data type since the user has no control over the set of pointers in the set, going by the basic concept of int is the set name, float is the set name, char is the set name of haracters, double is the set name of floats of high precision numbers, colour is the data type name in enum colour = { blue, red, yellow).

C 将指针数据类型称为用户数据类型。也许将指针数据类型视为用户数据类型是错误的,因为用户无法控制集合中的指针集合,根据 int 的基本概念是集合名称,float 是集合名称,char 是字符的集合名,double是高精度数字浮点数的集合名,color是enum中的数据类型名 color = { blue, red, yellow)。