Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C code that stores dates in an array of structures and implements the basic functionality provided below. The structure type youll define has

Write a C code that stores dates in an array of structures and implements the basic functionality provided below. The structure type youll define has a tag name Time_info and it stores day, month and year information. Implement 3 functions:

- insert: takes a Time_info variable and inserts it into an array of Time_info structures at the specified index. On success it returns 1 and on fail (invalid index) it returns 0.

- find: Takes an array of Time_info structures, a day, a month and a year and looks for a Time_info structure with the specified day, month and the year. It returns a pointer to Time_info structure if its found in the array, NULL otherwise.

- print: takes a Time_info variable and print its contents.

In main function

create an array of Time_info structures that stores valid random dates between 01.01.1990 - 31.12.2021. You can decide on the size of this array as you wish.

Create a Time_info variable and initialize it with a date you choose and test your functions with it. If inserting a Time_info variable into the array fails due to an invalid index print the message insertion failed on standard error stream.

If a Time_info variable is found in the array, print its index on the screen along with its contents using the print function you wrote.

If a Time_info variable is NOT found in the array, print the message Birthday not found on the screen.

Heres a sample output for the last 3 bullets listed above

image text in transcribed

Charubyy@arch-zenbook 14 exams]$ clang timestamps.c -o timestamps Charubyy@arch-zenbook 14 exams]$ ./timestamps insert failed... [harubyy@arch-zenbook 14 exams]$ clang timestamps.c -o timestamps Charubyy@arch-zenbook 14 exams]$ ./timestamps Found at index 4 day: 15, month: 3, year: 1990 Charubyu@arch-zenbook 14 exams]$ clang timestamps.c -o timestamps Charubyy@arch-zenbook 14 exams]$ ./timestamps Birthday not found Charubyy@arch-zenbook 14 exams]$ 0

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

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions