+ 1
TIMER
Is there a way to take “time” in the C languages like wait(5) second before execute my program
3 Respuestas
+ 3
threads are related to OS and putting them for sleep is a process of OS, not of the programming language. Starting from C++, developers added the std library that contains the std::thread and from there you can do sleep for this thread compatible on any OS.
So i can assume C not have any built-in function to make a sleep, you need to use a OS API function.
You can have a similar effect using what IAmSupreme doing in his code, but this will waste 1 whole vcore from your CPU while the thread looping in the delay() function, so your CPU load will be high all the time for no reason
+ 2
Yes there is, but doesn't not function as expected in soloLearn, check out the delay function in the code below
https://sololearn.com/compiler-playground/cMMswSCLjU64/?ref=app
0
In Python this is done with time.sleep(seconds). Most other languages also call it sleep, and Python is written in C++, so I would search for something similarly named.