Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _POSIX_C_SOURCE 199309L
- #include <stdio.h>
- #include <time.h>
- int main(int argc,char* argv[])
- {
- time_t now;
- time(&now);
- printf("Today is: %s", ctime(&now));
- for (int i = 0; i < 40; i++) {
- if (i % 7 == 0) {
- fprintf(stderr, "ERROR: process(%s): %d\n", argv[1], i);
- } else {
- fprintf(stdout, "process(%s):%d\n", argv[1], i);
- }
- // sleep for 1/10 second
- nanosleep((const struct timespec[]){{0, 100000000L}}, NULL);
- }
- time_t end;
- time(&end);
- printf("Elapsed time is: %2.3fs\n", difftime(end, now));
- printf("Elapsed time is: %2.3fs\n", (double)(end - now));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement