[英]Pointers and typedef in C
In C, 在C中
int* a, b;
Will make a
an integer pointer and b an integer. 将使
a
整数指针和b一个整数。
What about this? 那这个呢? Is
b
an integer or an integer pointer? b
是整数还是整数指针?
typedef int* foo;
foo a, b;
In C, typedef
is not a preprocessor directive: unlike #define
, it is not a textual substitution. 在C中,
typedef
不是预处理程序指令:与#define
不同,它不是文本替换。 It gives an alternative name to an existing type, so both a
and b
will be of the same type - namely, foo
, which is an alias for int*
. 它为现有类型提供了一个替代名称,因此
a
和b
将具有相同的类型,即foo
,它是int*
的别名。 Moreover, you can write this: 此外,您可以编写以下代码:
foo a, *b;
to make a
an int*
and b
an int**
. 使
a
int*
和b
一个int**
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.