now properly works, big thanks to @sulami

This commit is contained in:
Elliott Pardee 2015-06-12 04:19:19 -04:00
parent 93b618acfb
commit 10241092fa

View File

@ -1,4 +1,5 @@
#include <time.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@ -13,23 +14,24 @@ process(char *name)
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\n");
return -1;
if (file == 0) {
fprintf(stderr, "[err] no such file or directory\n");
return ENOENT;
}
int x;
while ((x = fgetc(file)) != EOF) {
printf("%c", x);
fflush(stdout);
nanosleep(&ts, NULL);
}
fclose(file);
return 0;
}
int
main(int argc, char *argv[])
{
process(argv[1]);
return 0;
return process(argv[1]);
}