C中的星号有什么作用?
C中的*是什么意思? 我在声明char或FILE变量时使用它( char = *test
)它如何改变变量的行为?
这种类型的*
称为“间接运算符”, *test
意味着“从指针test
点获取数据”。
char
保留用作关键字,因此除非将char
定义为宏,否则char
char = *test
将无法编译。
它取消引用一个指针:
*ptr = 42; // access the value that ptr points to, and set it to 42
或者它声明一个指针:
int* ptr; // the type of ptr is pointer to int