0

Please can anybody explain me what is the usleep() function that has been used in many places in the fifteen.c source code? What about the different tyoes of arguments that have been passed to the usleep() function like 20000?

1

As suggested in the program comment (man usleep for more):

DESCRIPTION
The usleep() function suspends execution of the calling thread for (at least) usec microseconds. The sleep may be lengthened slightly by any system activity or by the time spent processing the call or by the granularity of system timers.

It is used to slow down the game animation to "human" speed. If you were doing the suggested ./fifteen 3 < ~cs50/pset3/3x3.txt test without "pauses" (usleep) it would be darn near impossible to see what was happening.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .