Test precedence in pointer operations - C Pointer

C examples for Pointer:Pointer Variable

Description

Test precedence in pointer operations

Demo Code

#include <stdio.h>

int data[2] = {100, 200};

int moredata[2] = {300, 400};

int main(void)
{
    int * p1, * p2, * p3;
    //  www . j  ava2  s  . c  o  m
    p1 = p2 = data;
    p3 = moredata;
    printf("  *p1 = %d,   *p2 = %d,     *p3 = %d\n", *p1, *p2, *p3);
    printf("*p1++ = %d, *++p2 = %d, (*p3)++ = %d\n", *p1++, *++p2, (*p3)++);
    printf("  *p1 = %d,   *p2 = %d,     *p3 = %d\n", *p1, *p2, *p3);

    return 0;
}

Result


Related Tutorials