From 158049158f7f4c215bd2b69fe253d83ad17398b4 Mon Sep 17 00:00:00 2001 From: fshin1988 Date: Fri, 22 Sep 2017 20:17:18 +0900 Subject: [PATCH] Use read size instead of BUFFER_SIZE to count correctly --- wc-l-syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wc-l-syscall.c b/wc-l-syscall.c index fad2f59..27b0d24 100644 --- a/wc-l-syscall.c +++ b/wc-l-syscall.c @@ -43,7 +43,7 @@ do_word_count(int fd, const char *path) if (n < 0) die(path); if (n == 0) break; unsigned long i; - for (i = 0; i < BUFFER_SIZE; i++) { + for (i = 0; i < n; i++) { if (buf[i] == '\n') { count++; }