0

Hello, I got some code from:

http://stackoverflow.com/questions/1859201/add-seconds-to-a-date

this is the code:

#include <time.h>
#include <stdio.h>

int main()
{
    time_t now = time( NULL);

    struct tm now_tm = *localtime( &now);


    struct tm then_tm = now_tm;
    then_tm.tm_sec += 50;   // add 50 seconds to the time

    mktime( &then_tm);      // normalize it

    printf( "%s\n", asctime( &now_tm));
    printf( "%s\n", asctime( &then_tm));

    return 0;
}

Unfortuantely I do not know much about the code, and need to write a program that records a time, and compares two times. I do not know much about the datatypes time_t, struct tm, and the functions localtime, mktime, asctime, etc. Any information on this would be helpful. I am hoping to write some firmware which will activate after a certain amount of time, once I know how to use c time I will be able to finish the firmware.

2
Contributors
3
Replies
22
Views
4 Years
Discussion Span
Last Post by Unimportant
0

Yes, but is there any kind of online refrence I can use to read about the functions?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.