The C `clock()` function just returns a zero
clock()
reports CPU time used. sleep()
doesn't use any CPU time. So your result is probably exactly correct, just not what you want.
man clock
. It's not returning what you think it is. Also man gettimeofday
- it's more likely what you want.
clock_t is an integer type. You can't print it out with %f. See Fred's answer for why the difference is 0.