From the course: Code Clinic: C
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Putting the pieces together - C Tutorial
From the course: Code Clinic: C
Putting the pieces together
- [Instructor] For my solution I knew that the first step is to read the date range and then validate the input. The main function prompts for the date range and uses the scanf function to read the values. I toyed with the idea of adding seconds or removing minutes or changing the date format to two digit, because I type that often during testing, but I left it as four digits, and kept the minutes, but not the seconds. Next, the check input function is called to validate the date's input. It uses a lot of if statements to check specific ranges and every possibility to ensure that items aren't entered out of sequence. When a value is out of range or sequence the program stops. I can do further checking, for example, to ensure that February's date range is from one to 28 or 29 on a leap year, but that type of invalid data is caught when the program runs and fails to generate output. After input is checked, the read data function scans through the files for a matching start date. The…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.