是什么为int * PTR和INT * PTR在C之间的区别?

是什么为int * PTR和INT * PTR在C之间的区别?

问题描述:

我是位于C相当新的,我不知道以下两个变量声明之间的区别:

I am fairly new at C and I don't know the difference between the following two variable declarations:

int* ptr;
int *ptr;

我认为在声明为int * PTR; PTR 的价值不能,而它改变可以被改变的声明,为int * PTR;

I think that in the declaration int* ptr;, ptr's value cannot be changed whereas it can be changed for the declaration, int *ptr;

我不知道这是它虽然。

I am not sure if that is it though.

请帮助我了解两个声明背后的概念。

Please help me understand the concept behind the two declarations.

要编译器,有两个声明没有区别。

To the compiler, there is no difference between the two declarations.

要人的读者,前者可能意味着为int *类型适用于所有声明在同一语句。然而,*仅结合到下面的标识符。

To the human reader, the former may imply that the "int*" type applies to all declarations in the same statement. However, the * binds only to the following identifier.

例如,下面的两个语句声明只有一个指针。

For example, both of the following statements declare only one pointer.

int* ptr, foo, bar;
int *ptr, foo, bar;

该语句声明多个指针,其中$使用为int *,间隔P $ pvents。

This statement declares multiple pointers, which prevents using the "int*" spacing.

int *ptr1, *ptr2, *ptr3;