Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

typedef struct bday { int month; int day; int year; } bday_t; typedef struct node { char firstName[10]; char lastName[10]; bday_t bday; char song[10]; struct

typedef struct bday { int month; int day; int year;

} bday_t;

typedef struct node { char firstName[10]; char lastName[10]; bday_t bday; char song[10]; struct node* next;

} node_t;

Files:

You will create functions.h, functions.c, and driver.c files. driver.c Main will be included in driver.c. Driver.c should have minimal amount of code in it. Things you may have in the driver: Create the input and output files. These files will be given on the command line. You will need to open these files and check that they opened correctly. Call createList and then call the function printName, printBDay, and printSong. Also, dont forget to delete the nodes in the list. Points will be deducted if you have excessive code in driver.c

functions.h This file contains the declaration of the structs, all #includes, and the function prototypes. You must also include header guards in this file. Before each function prototype, you must have a detailed description of what the overall function does. What the parameters were and what is being returned.

void add(node_t **node, node_t **head) This is the function used to add the node to the linked list

node_t* readNodeInfo(FILE* input) This function will be used to read the data from the input file. This is where you will allocate the memory for the node that will eventually be added to the linked list. Using scanset conversion you will read the data and store it in the node allocated. You must also check the validity of the birthday. If the birthday is invalid, then do not add the node to the linked list. Returns the node created.

node_t* createList(FILE*, node_t**) This function is called in main and starts the process of creating the list. You will use a loop to read each record in the file then add the record to the list. Returns a pointer to the head of the list.

void PrintList(FILE*, node_t*) This function prints, to the output file, the data from the list. If the list is empty you are required to print a message, to stderr, indicating the list is empty and exit the program. If the list is not empty you are to print LIST INFO: then print the information for each node in the list. Described below is a function called printBorder which prints a line of 80 asterisk *. You will call this function before printing the list and after printing the list. An example of the print format is below: Last name, first name, birthday in the format of January 1, 2000, favorite song

Example:

********************************************************************************

LIST INFO: Feaster, Yvon, October 7, 1963, Im moving on

:

:

********************************************************************************

void PrintName(FILE*,node_t*) This function prints, to the output file, only the name from each node in the linked list. If the list is empty print, to stderr, a message indicating the list is empty and exit the program. If it is not empty print NAMES: then print the last name and first name. You are also required to call printBorder before and after the list of names.

Example:

********************************************************************************

Feaster, Yvon

:

:

********************************************************************************

void PrintBDay(FILE*,node_t *) This function prints, to the output file, the first and last name and the birthday from each node in the list. The format you must use is shown in the example below.

Example:

********************************************************************************

Yvon Feasters date of birth is October 7, 1963

:

:

********************************************************************************

void Song(FILE*,node_t *) This function prints, to the output file, the first and last name and favorite song from each node in the list. The format you must use is shown in the example below.

Example:

********************************************************************************

Yvon Feasters favorite song is Im moving on

:

:

********************************************************************************

void printBorder(FILE*) This function prints, to the output file, 80 asterisk *.

void print(void (*fp)(FILE*,node_t*),FILE*, node_t*) this is a function that you will use to call the print functions listed above. Notice this has a function pointer as a parameter. We have covered several examples of this concept in class.

void checkArgs(int) This function checks the number of command line arguments. If the incorrect number of arguments are passed to the command line you are to print a message, to stderr, indicating this and exit the program.

void checkFile(FILE*, char*) - - This function determines if the file opened successfully. If the file does not open successfully you must print to stderr a statement indicating this and exit the program. In your statement you must indicate which file did not open successfully.

void deleteList(node_t** ) After you are finished with the nodes in the list you need to give the memory back to the system. That is what this function does.

bool checkDate(bday_t ) This function is used to check the validity of the date. So, what does this mean? You must check that the month and days are within the appropriate bounds. The year should be within 1900 2020. In order to check the day of month, for February 29, you need to know if the year is Leap Year. You will need to call the function isLeapYear. If any of the test fail you must print, to stderr, which test failed. YOU ARE NOT TO EXIT THE PROGRAM AT THIS POINT. Remember when you are reading in the data I stated you are to check the validity of the date. This is the function you call to do that.

bool isLeapYear(int) return a bool that indicates rather the year passed to the function is leap year or not.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Project management skills and/or experience desirable

Answered: 1 week ago