From: hackbard Date: Tue, 20 Jan 2004 00:10:16 +0000 (+0000) Subject: initial checkin (gettimeofday example) X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=00b7011a623e31d5cc5b4ae3dd720b029aa4da73;p=my-code%2Fbeginners.git initial checkin (gettimeofday example) --- diff --git a/time-example.c b/time-example.c new file mode 100644 index 0000000..3fada4a --- /dev/null +++ b/time-example.c @@ -0,0 +1,37 @@ +/* + * example of gettimeofday usage + * + */ + +#include +#include +#include // only needed for time command (random seed) +#include + +int main(int argc,char **argv) { + + struct timeval foo1; + struct timeval foo2; + int sec,usec; + int i; + + srand(time(NULL)); // random seed + + printf("time 1:\n"); + gettimeofday(&foo1,NULL); + printf("seconds: %d \t usec: %d\n",(int)foo1.tv_sec,(int)foo1.tv_usec); + + while(i