Define Structures Containing Pointers - C Structure

C examples for Structure:Structure Value

Description

Define Structures Containing Pointers

Demo Code

#include <stdio.h>

struct intPtrs{/*from ww w.  jav a 2  s .c o m*/
        int *p1;
        int *p2;
};

int main (void){

    struct intPtrs pointers;
    int i1 = 100, i2;

    pointers.p1 = &i1;
    pointers.p2 = &i2;
    *pointers.p2 = -9;

    printf ("i1 = %i, *pointers.p1 = %i\n", i1, *pointers.p1);
    printf ("i2 = %i, *pointers.p2 = %i\n", i2, *pointers.p2);

    return 0;
}

Result


Related Tutorials