How to pause for loop for 1 second every iteration in C

1 Answer

0 votes
#include <stdio.h>
#include <unistd.h>

int main() {
	for (int i = 0; i < 5; i++) {
	    sleep(1);
        printf("%d\n", i);
	}

	return 0;
}




/*
run:

0
1
2
3
4

*/

 



answered Oct 5, 2021 by avibootz

Related questions

1 answer 166 views
1 answer 132 views
1 answer 168 views
2 answers 174 views
...