ok as a second part of my program i want to make. I want it to check how many weeks has passes since the program was first run. I've been reading the c library time header file to try and get an idea how to do this.
firstly i was going to do this
However i believe this only assigns the value of how many days months hours etc there has been since 1st of jan 1970 to the values in the currtim structure.Code:time_t tim; struct tm *currtim; time(&tim); currtim = localtime(&time);
So i thought about using
This sets the current date and time. However it gives it in a string format. Which means i cannot use difftime() to calculate the difference in times.Code:char timestr = ascitime(currtim);
finally i thought about using just
Then writing the value to a file. However im not sure how to write something that is a data type time_t to a file correctly, then reading it again and comparting it with endtime.Code:time_t start; time(&start);