【发布时间】:2012-07-16 06:10:34
【问题描述】:
可能重复:
In C, why is the asterisk before the variable name, rather than after the type?
Declaring pointers; asterisk on the left or right of the space between the type and name?
我用指针有一段时间了,用来声明指针之类的
int *x;
但是通过一些代码注意到,在某些情况下,* 似乎在数据类型之后,比如
void* setValue(){
/* */
}
有什么区别以及为什么要这样使用
【问题讨论】:
-
请注意:编译器将输入流分解为标记,然后处理这些标记。并且空格不是任何标记的一部分(尽管它可以用于分隔标记),因此在这两种情况下解析器看到的标记序列是
int、*、x、;。不管是写int*x;、int *x;、int* x;还是int * x;(甚至int/*obfuscating*/*/*comment*/x;---cmets都算作空白)。 -
完全没有区别。两者都使用。