Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <error.h>
- #include <errno.h>
- void stopwatch(double wait_time)
- {
- time_t t1, t2;
- for (t1 = t2 = time(NULL); difftime(t2, t1) < wait_time; t2 = time(NULL))
- ;
- }
- int
- main(int argc, char **argv)
- {
- FILE *fp;
- char buf[100];
- double wait_time;
- if (argc != 2)
- error(EXIT_FAILURE, errno, "need filename");
- if ((fp = fopen(argv[1], "r")) == NULL)
- error(EXIT_FAILURE, errno, "fopen: ");
- while (fscanf(fp, "%lf%100s", &wait_time, buf) != EOF)
- {
- printf("%s\n", buf);
- stopwatch(wait_time);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement