Put the data you got from the user in tm struct
And call function mktime
time_t mktime (struct tm * timeptr);
Here is an example how to use those functions -
Pregunta
Ok so im working on a timing program for long races in skiing and what not. I want to be able to have user input the starting time of race but I haven't found a good way to do that. Im using
struct tm * now = localtime( & maali );
to get current time (finish time) and difftime to calculate the difference. Finishing time is in 2013-12-21-16-32-00 format.
Edit: Ok ill elaborate a bit. I want the user to type the starting time in for example YYYY:MM:DD:HH:MM:SS format, which I could then use for calculations.
Edit 2.0
printf ("Enter year: "); scanf ("%d",&year);
printf ("Enter month: "); scanf ("%d",&month);
printf ("Enter day: "); scanf ("%d",&day);
printf ("Enter hour: "); scanf ("%d", &hour);
printf ("Enter minute: "); scanf ("%d", &minute);
printf ("Enter second: "); scanf ("%d", &second);
Thats where im at with getting the time. Getting that to a time_t is the problem.
Solución
Put the data you got from the user in tm struct
And call function mktime
time_t mktime (struct tm * timeptr);
Here is an example how to use those functions -