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


The thing is to take 2 time stamps: one at the beginning and one at the end of the game. Then you subtract the beginning value from the end to get the elapsed time.
In terms of
<time.h>, you probably want to callclock()to get these time stamps.And later:
That would give you the time in seconds, which you could make into hours by dividing it further by 3600.
(Note: It’s been a long time since I’ve programmed straight C so I may be off on something here? In C++, you would want to use
std::chrono::steady_clock::now()to get your time stamps, even thoughclock()still exists.)