关于*的简单C问题

Ami*_*mit 0 c variables pointers

我想知道这两行代码有什么区别?

int hi;
int *hi;
Run Code Online (Sandbox Code Playgroud)

在C编程语言中?

谢谢!阿米特

Rin*_*g Ø 8

int hi;
Run Code Online (Sandbox Code Playgroud)

int内存保留空间,每次引用时hi,您可以直接int在内存空间中读取或写入.

int *hi;
Run Code Online (Sandbox Code Playgroud)

保留一个空间pointer,以一个int在存储器中,每次hi使用时,该指针是读取或写入.这意味着你没有使用int一个指针,只有一个指向一个指针int- 指针必须存在一个int引用可行的东西.例如

 int hi;
 int *phi;
 phi = &hi; // phi references the int hi
 *phi = 3;  // set `hi` to 3
Run Code Online (Sandbox Code Playgroud)