Structure variables can be de ned just like variables

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: e has yet been allocated. Structure variables can be de ned just like variables of simple data types, as follows: struct date today today day month year CSC 1500 { Lecture 11 6 More Examples struct complex { double double } struct employee { char char float } enum suits {CLUBS, DIAMONDS, HEARTS, SPADES} struct card { enum suits int } suit rank name 50] position salary real imaginary CSC 1500 { Lecture 11 7 Accessing struct Members #include <stdio.h> struct date { int day int month int year } int main(void) { struct date today today.day = 25 today.month = 12 today.year = 1997 if (today.day==25 && today.month==12) printf("Merry X'mas!\n") return 0 } Members of a struct variables can be accessed using the selection operator '.'. The general format is as follows: struct_var.member where struct var is a struct variable and member is...
View Full Document

This note was uploaded on 05/23/2010 for the course COMPUTER S CSC1500 taught by Professor Fung during the Spring '10 term at CUHK.

Ask a homework question - tutors are online