Using Pointers to Structures - C Structure

C examples for Structure:Structure Value

Description

Using Pointers to Structures

Demo Code

#include <stdio.h>

struct date{/*from  w w  w  .j a  v  a  2s. c  om*/
        int month;
        int day;
        int year;
};

int main (void){
    struct date today, *datePtr;

    datePtr = &today;

    datePtr->month = 10;
    datePtr->day = 12;
    datePtr->year = 2018;

    printf ("Today's date is %i/%i/%.2i.\n", datePtr->month, datePtr->day, datePtr->year % 100);

    return 0;
}

Result


Related Tutorials