zoukankan      html  css  js  c++  java
  • *p++,*++p,*(p++),*(++p)

    直接上代码:

     1 #include <stdio.h>
     2 #include <stdlib.h>
     3 
     4 int main ()
     5 {
     6   int arry[] = {0,1,2,3};
     7   int val = 888;
     8   int *p, *tmp;
     9 
    10   p = &arry[0];
    11   val = *p;
    12   printf("p->0x%x, val=%d
    ", p, val);
    13 
    14   tmp = p;
    15   val = *p++;
    16   printf("*p++:   p->0x%x, val=%d
    ", p, val);
    17   p = tmp;
    18 
    19   tmp = p;
    20   val = *++p;
    21   printf("*++p:   p->0x%x, val=%d
    ", p, val);
    22   p = tmp;
    23 
    24   tmp = p;
    25   val = *(p++);
    26   printf("*(p++): p->0x%x, val=%d
    ", p, val);
    27   p = tmp;
    28 
    29   tmp = p;
    30   val = *(++p);
    31   printf("*(++p): p->0x%x, val=%d
    ", p, val);
    32   p = tmp;
    33 
    34   return 0;
    35 }

    输出:

    p->0xbf975cd4, val=0
    *p++:   p->0xbf975cd8, val=0
    *++p:   p->0xbf975cd8, val=1
    *(p++): p->0xbf975cd8, val=0
    *(++p): p->0xbf975cd8, val=1

    结论: 括号很重要

  • 相关阅读:
    连通块问题
    线性数据结构
    NOIP2018总结
    原码反码补码详解
    一些常用的算法技巧总结
    骗分导论
    模板
    模板
    AcWing
    AcWing
  • 原文地址:https://www.cnblogs.com/marvin-notes/p/4432309.html
Copyright © 2011-2022 走看看