Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delay a function in C? [duplicate]

Tags:

c

I can't find a viable guide so I am asking how do I delay a function in C, in other words, how do I make a program wait a certain number of seconds before continuing to execute other functions?

For example:

printf("First Function.\n");

//program waits a certain number of seconds before executing next command

printf("Second function executed after certain amount of seconds");

I want to know, what is the command I use to make this happen?

delay();

for me doesn't work by the way.

I must add, sleep() doesn't work either.

like image 574
octagonlord69 Avatar asked Feb 05 '23 13:02

octagonlord69


1 Answers

sleep is what you’re looking for.

printf("First Function.\n");

sleep(20);  // Replace 20 with the "certain amount"

printf("Second function executed after certain amount of seconds")
like image 134
idmean Avatar answered Mar 24 '23 05:03

idmean