Question: Download the program from the publisher: reminder.c Study the program so that you understand each statement in detail so you can answer the question in
- Download the program from the publisher: reminder.c
- Study the program so that you understand each statement in detail so you can answer the question in below.
Questions:
- List 5 of your personal events in the month of February, including the complete dates, the length and the description.
- Which data structure(s) is used to store the data in question one? Name the variable(s) and parts in detail by showing line numbers or coy the statements and explain so that a none-programmer can understand it.
- Draw the data structure and put your 5 events in the data structure in the drawing. (you must use the data structure provided in the reminder.c)
- Any other comments questions that you have, you can put it here
/* remind.c */
#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; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
