#include <stdio.h>

int main()
{
   int prices[3] = { 5, 4, 3 };
    printf("%u\n", *prices); /* 5 */
    printf("%u\n", prices); /* 首地址 且这个值每次运行是随机分配的*/
    printf("%u\n", *(prices+1)); /* 下一个地址指向的数据 */
}

 

#include <stdio.h>

int main()
{
int x=1, y=2, *px = &x, *py = &y;
    printf("%u\n", px);   // 3586201100
    printf("%u\n", *px);  // 1
    printf("%u\n", py);   // 3586201096
    printf("%u\n", *py);  // 2
    
    y = *px + 5;  //表示把x的内容加5并赋给y,*px+5相当于(*px)+5
    printf("%u\n", y);  //6
    y = ++*px;  //px的内容加上1之后赋给y,++*px相当于++(*px)
    printf("%u\n", y);  //2
    y = *px++;  //相当于y=*(px++)
    printf("%u\n", y);  //2
    py = px;  //把一个指针的值赋给另一个指针
    printf("%u", py);  // 3586201104
}

 

 posted on 2022-07-06 17:03  Real_Yuan  阅读(31)  评论(0)    收藏  举报