summaryrefslogtreecommitdiffstats
path: root/5/7.c
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2022-01-02 18:26:12 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2022-01-02 18:26:12 +0800
commit1596733e91f3fb9c484b6822684539bc004e0aa4 (patch)
tree0fd2394694a2fe906fed25a899f74415ac77a97e /5/7.c
parentcf8cc605e3454cc56b0b70d4d13f1c807730c9d6 (diff)
downloadk&r-exercises-1596733e91f3fb9c484b6822684539bc004e0aa4.tar.gz
5.7
Diffstat (limited to '5/7.c')
-rw-r--r--5/7.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/5/7.c b/5/7.c
index ed409f3..9dbe0ac 100644
--- a/5/7.c
+++ b/5/7.c
@@ -26,11 +26,10 @@ int main() {
int readlines(char **lines, int maxlines) {
int i, len;
- char *s;
+ char s[MAXLEN];
for (i = 0; i < maxlines; i++) {
- s = fgets(s, MAXLEN, stdin);
- if (!s)
+ if (!fgets(s, MAXLEN, stdin))
return i;
len = strlen(s);
strncpy(*lines, s, len - 1);