diff --git a/wc b/wc index 6d987bf..2b3fcac 100755 Binary files a/wc and b/wc differ diff --git a/wc.c b/wc.c index a154f59..b2047e6 100644 --- a/wc.c +++ b/wc.c @@ -2,10 +2,10 @@ #include // read, isatty // STDIN_FILENO -int process_fp(FILE* fp) +int process_fp(int filenum) { char buffer[1]; - while (read(0, buffer, sizeof(buffer)) > 0) { + while (read(filenum, buffer, sizeof(buffer)) > 0) { printf("%c", buffer[0]); } return 0; @@ -13,8 +13,7 @@ int process_fp(FILE* fp) int main(int argc, char** argv) { - // - if (!isatty(STDIN_FILENO)) { // check if stdin is coming from terminal or pipeline + if (!isatty(STDIN_FILENO)) { return process_fp(STDIN_FILENO); } else if(argc > 1){ printf("To do");