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) {
|
void print_list(struct event *head) {
|
||||||
while (head != NULL) {
|
while (head != NULL) {
|
||||||
printf("%s\n", head->date);
|
printf("%s\n", head->start_date);
|
||||||
printf("%s\n", head->summary);
|
printf("%s\n", head->summary);
|
||||||
head = head->next;
|
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));
|
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);
|
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;
|
new_node->next = *head;
|
||||||
*head = new_node;
|
*head = new_node;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Locate the node before the point of insertion
|
// Locate the node before the point of insertion
|
||||||
struct event* current = *head;
|
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;
|
current = current->next;
|
||||||
}
|
}
|
||||||
new_node->next = 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) {
|
while (head != NULL) {
|
||||||
if (strcmp(head->date, current_date) >= 0) {
|
if (strcmp(head->start_date, current_start_date) >= 0) {
|
||||||
pretty_print_date_time(head->date);
|
pretty_print_date_time(head->start_date);
|
||||||
printf("\n%s\n", head->summary);
|
printf("\n%s\n", head->summary);
|
||||||
}
|
}
|
||||||
head = head->next;
|
head = head->next;
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
struct event {
|
struct event {
|
||||||
char summary[256];
|
char summary[256];
|
||||||
char date[256];
|
char start_date[256];
|
||||||
struct event *next;
|
struct event *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
void print_list(struct event *head);
|
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 free_list(struct event *head);
|
||||||
void print_upcoming(struct event *head, char current_date[]);
|
void print_upcoming(struct event *head, char current_date[]);
|
||||||
|
Loading…
Reference in New Issue
Block a user