The link here says that gettimeofday() sets a structure which contains number of seconds and microseconds since Epoch (please tell me what Epoch is). With that thing in mind I set a structure before and after calling sleep function with parameter 3. So the total time difference setting of these structure is 3 seconds or 3000000 microseconds but it seem to give some wrong output. Where am I getting wrong?
#include<iostream>
#include<ctime>
#include<unistd.h>
#include<cstdio>
#include<sys/time.h>
using namespace std;
int main()
{
    struct timeval start,end;
    gettimeofday(&start,NULL);
    sleep(3);
    gettimeofday(&end,NULL);
    cout<<start.tv_usec<<endl;
    cout<<end.tv_usec<<endl;
    cout<<end.tv_usec-start.tv_usec;
    return 0;
}
 
     
    