Heya, i'm learning c at the moment and have a project i need to complete. I'd like to start of by saying that the course i'm on is pretty poorly taught. They taught us scanf printf basic arrays basic structures and fflush which doesn't even work on my compiler. We appear to be using sun systems that are well in excess of 10 years old and the compilers havn't been updated either. I''ve decided to do mine on my home pc with a copy of ubuntu i've installed instead and i've managed to get some of the poor teachng out of my head and good stuff in but i'm having some problems with some parts of my project.
PROBLEM NUMBER 1
Anyway, the problems i need help with are firstly to do with date. I'm making a basic video library system. I'm been reading through the documentation for <time.h> and i think i'm pretty sure i understand how to use strftime to get the current date and save it in integers and that shouldn't take me long to understand.
int current_day
int current_month
int current_year
the problem comes when i want to create a due date. Everytime a video is rented the due date will be 2 weeks later. I want to store these dates in the structure containing video information as integers like so
int current_day
int current_month
int current_year
so really i need to add 14 days to the current time and then format it with strftime and save it in those fields but i'm not sure how to go about it.
PROBLEM 2
I am using two structures in my database, customers and films, and they are linked by a borrowed by field which corresponds to the customer id in the customer field. the two structures look like this.
/* defining structure to hold customer details*/
typedef struct
{
int customer_id;
char surname [25];
char forename [15];
char phone_number[20];
int strikes;
int rentals;
} CUSTOMERS;
/* This is a variable that stores customer details */
CUSTOMERS customer_details [500];
/* defining structure to hold film details*/
typedef struct
{
int film_id;
char film name [50];
int genre;
int type;
int due_day;
int due_month;
int due_year;
} FILMS;
/* This is a variable that stores customer details */
FILMS film_details [1000];
I'm sure this is an aweful implementation but i've just been trying to get along with what i have learned. I don't really have time to redo everything a cleverer way so thats the data will be stored. My problems arise when i bring files into the equation. I need to be able to save each structure into a file on program exit(or when new entries are made) and then retrieve them from the file when i open the program again. I have absolutely no idea where to start with this. How could i go about implementing this in my project?