The example:
#include <iostream>
using namespace std;
int main()
{
time_t time_start, time_end;
time(&time_start);
sleep(5);
time(&time_end);
cout<<difftime(time_end, time_start)<<endl; // 5
clock_t clock_start, clock_end;
clock_start = clock();
sleep(5);
clock_end = clock();
cout<<(clock_end-clock_start)/CLOCKS_PER_SEC<<endl; // 0
return 0;
}
It is clear to see that time_t is used to test the real time, while clock_t is used to test the cost of CPU time, because sleep(5) don't occupy any CPU resource.