#include <time.h>
clock_t clock(void);
#include <stdio.h>
#include <time.h>
int main()
{
printf ("ticks:%lld\n", clock());
sleep (5);
printf ("ticks:%lld\n", clock());
return 0;
}
$ ./clock
ticks:577732307436175360
ticks:577732307436175360
#include <stdio.h>
#include <time.h>
int main()
{
int seconds = 5;
clock_t ticks;
ticks = clock();
printf ("%lld\n", ticks/CLOCKS_PER_SEC);
while((clock()/CLOCKS_PER_SEC - ticks/CLOCKS_PER_SEC) < seconds);
printf ("elapsed time:%d\n", clock()/CLOCKS_PER_SEC - ticks/CLOCKS_PER_SEC);
printf ("\a");
return 0;
}
$ ./clock
5091074385217847296
elapsed time:5
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |