是什么为int * PTR和INT * PTR在C之间的区别? [英] What is the difference between int* ptr and int *ptr in C?

查看:245
本文介绍了是什么为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;

这篇关于是什么为int * PTR和INT * PTR在C之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆