hello, i’m new to programming in i’m trying to solve this exercise in C, basically it’s the amount of passed hours between the start of a game and it’s end, if the game started at 16 and ended at 2 the result is a game with 10 hours(in different days) i know i can to it more manually, but i wanted to somehow use the <time.h> to learn how to use a header etc, can someone help me?, thank you all

  • Juniper@skein.city
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Most of my hobby programming is in ANSI C and C99, so I’m unfortunately far too aware of the weird and counter-intuitive things the C and POSIX standards say. :P

    clock() is fantastic for sub-second timings, such as deltatimes in games, or peripheral synchronization, which matches the use case you mention very well. I recommended time() over it as OP’s use case is for calculating the amount of hours a user has had their software open, and unix timestamps are the perfect mechanism to do that in my opinion.