Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #define MAX_REMIND 50 /* maximum number of reminders */ #define MSG_LEN 60 /* max length of reminder message */ int read_line(char str[], int

#include #include

#define MAX_REMIND 50 /* maximum number of reminders */ #define MSG_LEN 60 /* max length of reminder message */

int read_line(char str[], int n);

int main(void) { char reminders[MAX_REMIND][MSG_LEN+3]; char day_str[3], msg_str[MSG_LEN+1]; int day, i, j, num_remind = 0;

for (;;) { if (num_remind == MAX_REMIND) { printf("-- No space left -- "); break; }

printf("Enter day and reminder: "); scanf("%2d", &day); if (day == 0) break; sprintf(day_str, "%2d", day); read_line(msg_str, MSG_LEN);

for (i = 0; i < num_remind; i++) if (strcmp(day_str, reminders[i]) < 0) break; for (j = num_remind; j > i; j--) strcpy(reminders[j], reminders[j-1]);

strcpy(reminders[i], day_str); strcat(reminders[i], msg_str);

num_remind++; }

printf(" Day Reminder "); for (i = 0; i < num_remind; i++) printf(" %s ", reminders[i]);

return 0; }

int read_line(char str[], int n) { int ch, i = 0;

while ((ch = getchar()) != ' ') if (i < n) str[i++] = ch; str[i] = '\0'; return i; }

** Hello! I could use some help please. I am trying to learn about this code so could someone break it down line by line telling me what it does and why? It would be most helpful thank you in advance.**

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

Multidimensional Array Data Management In Databases

Authors: Florin Rusu

1st Edition

1638281483, 978-1638281481

More Books

Students also viewed these Databases questions

Question

Super Weapons developmentis the hit ratio optimized? LO8

Answered: 1 week ago

Question

Address an envelope properly.

Answered: 1 week ago

Question

Discuss guidelines for ethical business communication.

Answered: 1 week ago