W11-Struct-File IO
W11-Struct-File IO
Week 09
Struct – File IO
1
Content
In this lab, we will study the following topics:
• How to define and use a struct.
• How to load data from text file.
• How to save data to text file.
2
Introduction to Programming W09 – Struct – File IO
2
Assignments
A: YY = 05
H: YY = 20: at least 7 in struct Date + at least 7 in struct Student + at least 6 in struct Course
2.1 Assignment 1
Define a struct Date (day, month, year) and the following functions.
1. Input a date.
2. Output a date (yyyy-MM-dd).
3. Output a date with a given format. For example: yy: 70, yyyy: 1970, M: 8 or 12, MM: 08 or 12,
MMM: Jan … Dec, d: 1 or 29, dd: 01 or 29.
outputDateWithFormat(d1, "yyyy-MM-dd"); // 2019 - 12 - 04
outputDateWithFormat(d1, "MMM dd yy"); // Dec 12 19
3
Introduction to Programming W09 – Struct – File IO