Homework 12: fscanf
Name: _____________________________________________ Alpha: ___________________
Describe help received: ________________________________________________________
- Due before class on Wednesday, February 8
- This homework contains code to be submitted electronically.
Put your code in a folder called
hw12
and submit using the204sub
command. - This is an electronic homework and you do not need to print out anything to turn in during class.
Assignment
- Required reading: Sections 3 (Pointers) and 4 (fscanf) from the Unit 4 notes,
-
Write a program called
age.c
that reads a name and a birthday such as "Philip 1/31/1937
" and prints out a line with their age as of February 6, 2017, for example "Philip is 80 years old.
"roche@ubuntu$
./age
Philip 1/31/1937
Philip is 80 years old.
roche@ubuntu$
./age
Steve 10/3/1936
Steve is 80 years old.
You must use a
fscanf
statement to read in the input line! Note that someone born on February 6 would be considered to have their birthday already, so someone born on 2/7/2016 would be0 years old
while someone born on 2/6/2016 would be1 years old
.