10StructuresLarge

10StructuresLarge - CMSC 106 Lecture Set#10 Structures Set Started Wednesday November 9 2011 Structured Types array composite variable all elements

Info iconThis preview shows pages 1–4. 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.
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 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]); 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;
Background image of page 2
3 typedef typedef struct { char month[4]; int day; int year; } Date;
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/12/2012 for the course CMSC 106 taught by Professor Staff during the Fall '07 term at Maryland.

Page1 / 5

10StructuresLarge - CMSC 106 Lecture Set#10 Structures Set Started Wednesday November 9 2011 Structured Types array composite variable all elements

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

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