10StructuresSmall

10StructuresSmall - CMSC 106 Lecture Set#10 Structures Set...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CMSC 106 Lecture Set #10 - Structures Set Started: Wednesday, November 9, 2011 Structured Types s array- composite variable, all elements have same type. s structure (or struct )- composite variable with components (called members or fields) which can be different types. parallel arrays char month[][4]= {"Feb", "Feb", "Mar"}; int day[]= {17, 25, 4}; int year[]= {1998, 1998, 1998}; printf("%s %d %d", month[1], day[1], year[1]);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 structure struct date { char month[4]; int day; int year; }; s 3 fields or members: s an array of 4 characters named month, s an int named day, s an int named year s date = structure tag or the name of this type of structure s month, day, and year are not individual variables, but part of a larger object s Structure field names can be the same as individual variables or the same as field names in other structures without conflict. s Declaring a variable s struct date myDay; s struct date d1, d2; typedef typedef struct { char month[4]; int day; int year;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

10StructuresSmall - CMSC 106 Lecture Set#10 Structures Set...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online