making it neater
This commit is contained in:
parent
437f9c66e1
commit
1dd3e86ede
@ -2,22 +2,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int process(char *name, struct timespec *ts);
|
||||
static int process(char *name);
|
||||
|
||||
static int
|
||||
process(char *name, struct timespec *ts)
|
||||
process(char *name)
|
||||
{
|
||||
FILE *file = fopen(name, "r");
|
||||
struct timespec ts;
|
||||
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 10 * 1000000;
|
||||
|
||||
if (file == 0){
|
||||
fprintf(stderr, "[err] you either gave me an invalid file, or no file at all");
|
||||
fprintf(stderr, "[err] you either gave me an invalid file, or no file at all\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int x;
|
||||
while ((x = fgetc(file)) != EOF) {
|
||||
printf("%c", x);
|
||||
nanosleep(ts, NULL);
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -26,13 +30,6 @@ process(char *name, struct timespec *ts)
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *argv0;
|
||||
|
||||
struct timespec ts;
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 10 * 1000000;
|
||||
|
||||
process(argv[1], &ts);
|
||||
|
||||
process(argv[1]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user