changed member date to start_date
This commit is contained in:
parent
36ede8c52d
commit
3a53493e74
@ -6,25 +6,25 @@
|
||||
|
||||
void print_list(struct event *head) {
|
||||
while (head != NULL) {
|
||||
printf("%s\n", head->date);
|
||||
printf("%s\n", head->start_date);
|
||||
printf("%s\n", head->summary);
|
||||
head = head->next;
|
||||
}
|
||||
}
|
||||
|
||||
void sorted_insert(struct event** head, char date[], char summary[]) {
|
||||
void sorted_insert(struct event** head, char start_date[], char summary[]) {
|
||||
struct event *new_node = malloc(sizeof(struct event));
|
||||
strcpy((*new_node).date, date);
|
||||
strcpy((*new_node).start_date, start_date);
|
||||
strcpy((*new_node).summary, summary);
|
||||
|
||||
if (*head == NULL || strcmp((*head)->date, new_node->date) >= 0) {
|
||||
if (*head == NULL || strcmp((*head)->start_date, new_node->start_date) >= 0) {
|
||||
new_node->next = *head;
|
||||
*head = new_node;
|
||||
}
|
||||
else {
|
||||
// Locate the node before the point of insertion
|
||||
struct event* current = *head;
|
||||
while (current->next!=NULL && strcmp(current->next->date, new_node->date) < 0) {
|
||||
while (current->next!=NULL && strcmp(current->next->start_date, new_node->start_date) < 0) {
|
||||
current = current->next;
|
||||
}
|
||||
new_node->next = current->next;
|
||||
@ -44,10 +44,10 @@ void free_list(struct event *head)
|
||||
}
|
||||
}
|
||||
|
||||
void print_upcoming(struct event *head, char current_date[]) {
|
||||
void print_upcoming(struct event *head, char current_start_date[]) {
|
||||
while (head != NULL) {
|
||||
if (strcmp(head->date, current_date) >= 0) {
|
||||
pretty_print_date_time(head->date);
|
||||
if (strcmp(head->start_date, current_start_date) >= 0) {
|
||||
pretty_print_date_time(head->start_date);
|
||||
printf("\n%s\n", head->summary);
|
||||
}
|
||||
head = head->next;
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
struct event {
|
||||
char summary[256];
|
||||
char date[256];
|
||||
char start_date[256];
|
||||
struct event *next;
|
||||
};
|
||||
|
||||
void print_list(struct event *head);
|
||||
void sorted_insert(struct event **head, char date[], char summary[]);
|
||||
void sorted_insert(struct event **head, char start_date[], char summary[]);
|
||||
void free_list(struct event *head);
|
||||
void print_upcoming(struct event *head, char current_date[]);
|
||||
|
Loading…
Reference in New Issue
Block a user