this post was submitted on 15 Jun 2023
0 points (NaN% liked)

Programming

13342 readers
11 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 1 year ago
MODERATORS
 

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

top 1 comments
sorted by: hot top controversial new old
[–] Tschuuuls@feddit.de 0 points 1 year ago

You save the unix timestamp at the beginning of the game and the end of the game (or use the current one). With this timestamps you can use functions to calculate length etc. For example https://cplusplus.com/reference/ctime/difftime/ You then can convert those into a better format. More info here https://cplusplus.com/reference/ctime/

Also chatgpt could help in those cases, if you don't want to wait for a answer on here :P