您的位置:首页 > 博客中心 > 互联网 >

(*p)++和*(p++)和*p++的区别

时间:2022-04-30 09:55

 * 和++优先级是同一级别,同一级别按照从右往左的顺序计算

所以:  *p++等价于*(p++) 

char *a="this a book";
   char *p = a;
   p++;
   printf("%c\n", *p);//output:h
   *p++;
   printf("%c\n", *p);//output:i

   /* overflow
   char x = (*p)++;
   printf("%d\n", x);
   */
   while (*p != ‘\0‘) {
       printf("%c", *p++);//is
   }
   printf("\n");

本类排行

今日推荐

热门手游