Have the program print an error message and ignore a


(a) Have the program print an error message and ignore a reminder if the corrsponding day is negative or larger than 31 (using the continue statement)
(b) Allow the user to enter a day, a 24-hout time, and a reminder. The printed reminder list should be sorted first by day, then by time. (The original program allows the user to enter a time, but it's treated as part of the reminder)
(c) Have the program print a one-year reminder list. require the user to enter days in the form month/day.

Here is the given program (I sure hope this pastes correctly):

#include "remind.h"

/* Prints a one-month reminder list */

#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 --\n");

break;

}

printf("Enter day and reminder: ");

scanf("-", &day);

if (day == 0)

break;

sprintf(day_str, "-", 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("\nDay Reminder\n");

for (i = 0; i < num_remind; i++)

printf(" %s\n", reminders[i]);

return 0;

}

int read_line(char str[], int n)

{

int ch, i = 0;

while ((ch = getchar()) != '\n')

if (i < n)

str[i++] = ch;

str[i] = '\0';

return i;

}

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Have the program print an error message and ignore a
Reference No:- TGS0660864

Expected delivery within 24 Hours