time_t first, second;
first = time(NULL);
// 你的程序 ...............
second = time(NULL);
printf("The difference is: %f seconds\n",difftime(second,first));
// 分钟
int imin = (isec / 60) % 60;
// 小时
int ihour = isec / 60 / 60;
//秒
int isec = (isec % 60) % 60;
原文地址:http://www.cnblogs.com/ADaii/p/3700439.html