Skip to content

Commit 92bdb15

Browse files
authored
Update snipMemory5.cpp
1 parent f84d594 commit 92bdb15

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

codereview101/snipMemory5.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11

2-
int len = 0, total = 0;
2+
int len = 0, total = 0, CHUNK_SIZE = 16, BUFFER_SIZE = 256, chunks = 0;
3+
char chunk[CHUNK_SIZE];
4+
char buffer[BUFFER_SIZE];
35
while(1){
4-
fgets(buff1, MAX_SIZE, stdin);
5-
len = strnlen(buff1, MAX_SIZE);
6+
fgets(chunk, CHUNK_SIZE, stdin);
7+
len = strnlen(chunk, CHUNK_SIZE);
68
total += len;
7-
if(total <= MAX_SIZE) strncat(buff2, buff1, len);
9+
if(total <= MAX_SIZE){
10+
strncat(buffer, chunk, CHUNK_SIZE);
11+
chunks++;
12+
}
813
else break;
914
}
10-

0 commit comments

Comments
 (0)