Question
Write a program that uses C style string functions to create data files usable as the input files for the Airline assignment You will be
Write a program that uses C style string functions to create data files usable as the input files for the Airline assignment You will be provided with a sample input file called inputdata.txt. It will contain sample data that could be used for the Airline assignment o This file will contain input strings in a comma separated value format. Each input line will contain, in order and separated by commas: 1.City name 2.Flying time 3.Layover time o Both the flying time and layover time will be formatted with an hours portion, a colon, and two digits representing the minutes. For a valid time, the minutes portion will be two digits and the hours portion will be either one or two digits (which might be 0). You must create two output files. theTimes.dat will be a binary file containing the flying and layover times. theCities.txt will be a text file containing the city names. Both files must be created to conform to the requirements of the Airline assignment. After opening the input file as a text file, loop, reading each line in the file one at a time. o For each line 1.separate the input line into its component parts as described below. 2.output the city name to the text city name file. 3.output the times to the binary time file. o There could be any number of input lines. After the loop is finished, close the files Do error checking on all file I/O function calls, with appropriate error messages. Do not get user input from the keyboard in your program. At all. I'm serious. Assume a maximum string length of 80 characters (so your array must be 81 bytes long). Quit the program without processing further input upon an error occurring. All error messages must have appropriate wording and correct spelling and grammar. Do not use strtok(), global va riables, goto , or exit() . Using any of these will result in a mark of 0. Appropriate programming style as required in the course must be used . Function Creation Requirements Function name: parseLine o Description: Separates a string into its component parts, as described by the parameters. The component parts are used to fill a struct that is pointed to by the second parameter. o Parameters: char inputline[]: input line containing city name and time information (originating from the input file) struct CityInfo *pCityInfo: pointer to a struct that is filled in with the cityname and time information from the input line o Returns: 1 if OK, 0 if there are problems with the data Function name: parseTime o Description: Separates a time string into hours and minutes o Parameters: char inputTime[]: string containing a time in the format hhh:mm (where there are one to three digits in the hour portion but exactly two digits in the minutes portion) char *pHours: pointer to hours portion of the time char *pMinutes: pointer to minutes portion of the time o Returns: 1 if OK, 0 if there are problems with the data For both of the above functions, the expectation is that you will check for the following possible problems with the data (as appropriate): 1.minutes exceeding 59 2.missing commas separating the components of the input line 3.missing colons separating the hours from the minutes of the time although there are many other possible problems that could happen in the real world, no other problems with the data need to be accounted for Design Requirements You must use parseLine to separate the components of the input line. Call it from main(). You must call parseTime from within parseLine to separate the components of the two times. You must use C style strings, not C++. You will find that string related C library functions (such as those mentioned in lecture) will be your friends However, you must not use the strtok() function or any other third party or compiler provided tokenizing function (i.e. you need to do the separation of the components yourself). Do not display any error messages in parseLine or parseTime. Any error messages should be displayed only in main()
inputData.txt Data File Toronto,4:15,0:55 Atlanta,5:33,10:44 Kansas City,6:00,11:22 Anchorage,12:22,0:00
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started