Skip to content

Commit

Permalink
Use read size instead of BUFFER_SIZE to count correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
fshin1988 committed Sep 22, 2017
1 parent d1be9e6 commit 1580491
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion wc-l-syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down

0 comments on commit 1580491

Please sign in to comment.