An example of pointer arithmetic

This is an example C program demonstrating pointer arithmetic.

#include <stdio.h>

int main ()
    int x;
    int * x_p;

    x_p = x;
    printf ("%p\n", x_p);
    x_p = x_p + 1;
    printf ("%p\n", x_p);
    return 0;


The output of the example looks like this:


Notice here that the second value is four bytes beyond the first value.

Copyright © Ben Bullock 2009-2021. All rights reserved. For comments, questions, and corrections, please email Ben Bullock ( or use the discussion group at Google Groups. News about the site. / Privacy / Disclaimer