c_cpp 指针(*),地址在(@)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 指针(*),地址在(@)相关的知识,希望对你有一定的参考价值。

main(){
  int x = 5;
  int *xPtr;//declare variable xPtr with the type pointer to an int. can also be written as int * xPtr. both correct and the same
  //The declaration of the pointer tells you the name of the variable and type of variable that this pointer will be pointing to. 
  xPtr = &x;//make xPtr point at x,by pointing at x's address(hence &x)
  *xPtr = 6;//dereferencing. changes value of the box(x) which xPtr is pointing at.
  //if *x isn't declaration, then we can always understand it as "the value of the box x is pointing at"
  //Dereferencing a pointer means using the * operator (asterisk character) 
  //to retrieve the value from the memory address that is pointed by the pointer
  printf("x = %d\n",x); //prints 6
}

以上是关于c_cpp 指针(*),地址在(@)的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp 在c中移动一个字节指针

c_cpp 指针迭代与C中的int指针

c_cpp 在c中使用void指针数组的一些练习

c_cpp C ++智能指针

c_cpp C ++指针

c_cpp const指针