diff --git a/c/typeprint.c b/c/typeprint.c index f5e5583..3c65c14 100644 --- a/c/typeprint.c +++ b/c/typeprint.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -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]); }