2024-12-13 22:56:16 +01:00
|
|
|
/* Create a database and handel it
|
|
|
|
* Created by Jan on 13.12.2024.
|
2024-12-10 22:12:25 +01:00
|
|
|
* INPUT: query for previous state
|
2024-12-11 13:03:28 +01:00
|
|
|
* linked list of tasks to store
|
2024-12-10 22:06:49 +01:00
|
|
|
*
|
|
|
|
* OUTPUT:
|
2024-12-11 13:03:28 +01:00
|
|
|
* linked list of tasks from file
|
2024-12-10 22:06:49 +01:00
|
|
|
* OK
|
|
|
|
*
|
|
|
|
*
|
2024-12-09 19:27:50 +01:00
|
|
|
*/
|
2024-12-10 17:42:45 +01:00
|
|
|
|
2024-12-13 22:56:16 +01:00
|
|
|
|
2024-12-10 22:06:49 +01:00
|
|
|
#include <stdio.h>
|
2024-12-13 22:56:16 +01:00
|
|
|
#include <stdlib.h>
|
2024-12-13 18:44:02 +01:00
|
|
|
#include <time.h>
|
|
|
|
#include "planner.h"
|
2024-12-13 22:56:16 +01:00
|
|
|
#include "list.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
write a complete linkedlist to a csv file.
|
|
|
|
*/
|
|
|
|
void write_linkedlist_to_csv(llist* head, const char* filename) {
|
|
|
|
//Open file with write permision
|
|
|
|
FILE* file = fopen(filename, "w");
|
|
|
|
//if there is no file or a wrong file path you becom an error
|
|
|
|
if (file == NULL) {
|
|
|
|
printf("Could not open file %s\n", filename);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
//write the file head
|
|
|
|
//fprintf(file, "**********************");
|
2024-12-13 18:44:02 +01:00
|
|
|
|
2024-12-13 22:56:16 +01:00
|
|
|
// iteration through the list and write data to csv
|
|
|
|
llist* current = head;
|
|
|
|
while (current != NULL) {
|
|
|
|
//fprintf(file, "%d \n", current->id );
|
|
|
|
current = current->next;
|
|
|
|
}
|
|
|
|
fclose(file)
|
|
|
|
}
|
|
|
|
}
|