0 like 0 dislike
13.3k views

The remind.c program prints a one-month list of daily reminders.

• The user will enter a series of reminders, with each prefixed by a day of the month.

• When the user enters 0 instead of a valid day, the program will print a list of all reminders entered, sorted by day. Use LIFO ( Last In First Out) for reminders in the same day.

• Ignore a reminder if the corresponding day is negative or larger than 31

Example input:

24 Susan's birthday
5 9:00 - Meeting with Daniel
5 7:00 - Dinner with Marge and Russ
26 Movie - "Chinatown"
7 10:30 - Dental appointment
12 15:00 Movie - "Dazed and Confused"
5 Saturday class
12 Saturday class
12 20:00 - Theatre - "Hamlet"
0

Example output:

Day Reminder
  5 Saturday class
  5 7:00 - Dinner with Marge and Russ
  5 9:00 - Meeting with Daniel
  7 10:30 - Dental appointment
 12 20:00 - Theatre - "Hamlet"
 12 Saturday class
 12 15:00 Movie - "Dazed and Confused"
 24 Susan's birthday
 26 Movie - "Chinatown"

 

asked in C by (12.1k points)
edited by | 13.3k views
1 0
Called for Help
0 0
Called for Help
0 0
Called for Help

111 Answers

0 like 0 dislike
Hidden content!
#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)

{
* **** *** * *** * * * * * * * ** ** ****
* * * * ***** * * ** *** day_str[3], msg_str[MSG_LEN+1];
* * *** * * ** * * * *** * day, i, j, num_remind = 0;


* * * ** * ** * *** * * (;;)
****** ****** * * ****
**** ** **** * * **** * * * * ****** * ** * * * (num_remind == MAX_REMIND)
* * ** * * * * * * ** * *** * * * * * *
* ** ** ** ** * **** ** * * ** * * * * ***** * * ** * * ****** No space left --\n");
* * ** **** * *** * ****** ********* **** ** ** * **** *** *** **
**** * **** *** * * *** *** *** ** * ****
* *** * * *** *** * * * ** *** * * * * * * * day and reminder: ");
* * ****** *** * ** ** **** ** * * **** * **** ****** * &day);
** * * * * **** * ******* * ** ** * * * * (day == 0)
** * * * * * * **** ***** ***** * *** ** ** ** *** ** * * *
* * * * * *** *** **** * ***** * * * ** *** ***** ** ** ** * day);
** * * *** ***** ** ** * *** * * **** * * *** * * * MSG_LEN);


** * ** **** ****** * *** ** ** ** * * ** *** (i = 0; i < num_remind; i++)
** **** *** * * * * *** ***** * * ** * * ** * * *** * * ** *** (strcmp(day_str, reminders[i]) < 0)
* * * ****** * * **** * ** ** **** * * ** ** ** *** ***** * * * ** ***** ** * * *
*** * * * * ** * * * ** **** ** * ** * (j = num_remind; j > i; j--)
* * * * * * * ****** * * **** ** * ** ** ** ** ****** *** ****** ** *** ** reminders[j-1]);
** * * * * ** * ** * * ** ** * * ****** * day_str);
** ***** **** ** * *** * ******** * * ** ** * *** msg_str);


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


** * * ** *** *** ** ** **** ** * ***
** * ** ** * *** ** (i = 0; i < num_remind; i++)
** ** ** * * ** *** *** ** **** * * ** ** * * ** **** %s\n", reminders[i]);


***** * * * ** * *** * ** 0;

}

int read_line(char str[], int n)

{
* * * ***** ** * ** ch, i = 0;


*** ***** *** *** * * *** * ((ch = getchar()) != '\n')
* * ** * ** * ** ** * * * * * *** ** (i < n)
* ******* * * * *** * ** *** ** *** * * * ** * *** * ** **** = ch;
*** ** **** * * ** * * = '\0';
*** ** * ** ******** ** ** * i;

}
answered by (-48 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.80.197
©2016-2025

Related questions

0 like 0 dislike
50 answers
[Exercise] Coding (C) - asked Mar 16, 2017 in C
ID: 22973 - Available when: Unlimited - Due to: Unlimited
| 6.3k views
0 like 0 dislike
90 answers
[Exercise] Coding (C) - asked Mar 16, 2017 in C
ID: 22972 - Available when: Unlimited - Due to: Unlimited
| 11.4k views
12,783 questions
183,442 answers
172,219 comments
4,824 users