Question: { char line [ 2 5 6 ] ; while ( 1 ) { / / Read input line fgets ( line , sizeof (
char line; while Read input line fgetsline sizeofline stdin; Remove newline character if present linestrcspnline
; End of input check if strcmpline break; Define variables to store extracted parts of the date char month day year; int monthNum, dayNum, yearNum; Extract the parts of the date: Month Day, Year int i j ; Extract the month name the first word while i strlenline && isspacelinei monthj linei; monthj; Nullterminate the month string Skip the space after the month while i strlenline && isspacelinei i; Extract the day the number before the comma j ; while i strlenline && linei dayj linei; dayj; Nullterminate the day string Skip the comma and the space while i strlenline && linei isspacelinei i; Extract the year the number after the comma j ; while i strlenline && linei yearj linei; yearj; Nullterminate the year string Check if the month is valid monthNum monthToNummonth; if monthNum continue; Invalid month Check if the day and year are valid numbers if isDigitsdayisDigitsyear continue; Invalid day or year Convert day and year to integers dayNum atoiday; yearNum atoiyear; Print the date in the required format: MonthDayYear printfddd
monthNum, dayNum, yearNum;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
