Home / Expert Answers / Computer Science / complete-main-to-read-dates-from-input-one-date-per-line-each-date-39-s-format-must-be-as-follows-pa938

(Solved): Complete main() to read dates from input, one date per line. Each date's format must be as follows: ...



student submitted image, transcription available belowstudent submitted image, transcription available below
Complete main() to read dates from input, one date per line. Each date's format must be as follows: March 1, 1990. Any date not following that format is incorrect and should be ignored. Use the substring() function to parse the string and extract the date. The input ends with -1 on a line alone. Output each correct date as: 3-1-1990. Ex: If the input is: March 1, 1990 April 21995 December 13, 2003 -1 March 1, 1990 April 21995 December 13, 2003 then the output is: Use the provided GetMonthAsInt() function to convert a month string to an integer. If the month string is valid, an integer in the range 1 to 12 inclusive is returned, otherwise 0 is returned. Ex: GetMonthAsInt("February") returns 2 and GetMonthAsInt("7/15/20") returns 0. main.c Load default template... \#include ?stdio.h? \#include ?string.h? int GetMonthAsInt(char *monthstring) \{ int monthint; if (strcmp(monthstring, "January") == 0 ) \{ monthInt ; \} else if (strcmp(monthstring, "February") == 0 ) \{ monthInt ; \} else if (strcmp(monthstring, "March") == 0) \{ monthint ; \} else if (strcmp(monthstring, "April") == 0) \{ monthInt ; \}) else if (strcmp(monthstring, "May") == 0 ) \{ monthInt ; \} else if (strcmp(monthstring, "June") == 0 ) \{ monthInt ; \} else if (strcmp(monthstring, "July") == 0 ) \{ monthInt ; 3 else if (strcmp(monthstring, "August") ) \{ monthInt ; \} else if (strcmp(monthstring, "September") ) \{ monthInt ; \} else if (strcmp(monthstring, "October") == 0 ) \{ monthInt ; \} else if (strcmp(monthstring, "November") ) \{ monthInt ; \}) else if (strcmp(monthstring, "December") ) \{ monthInt ; \} else \{ monthInt ; \} return monthInt; \} int main(void) \{ // TODO: Read dates from input, parse the dates to find the ones in the correct format, and output in m-d-yyyy format return 0; \}


We have an Answer from Expert

View Expert Answer

Expert Answer



We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe