diff options
| author | Sadeep Madurange <smadurange@users.noreply.github.com> | 2022-01-02 18:26:12 +0800 |
|---|---|---|
| committer | Sadeep Madurange <smadurange@users.noreply.github.com> | 2022-01-02 18:26:12 +0800 |
| commit | 1596733e91f3fb9c484b6822684539bc004e0aa4 (patch) | |
| tree | 0fd2394694a2fe906fed25a899f74415ac77a97e /5 | |
| parent | cf8cc605e3454cc56b0b70d4d13f1c807730c9d6 (diff) | |
| download | k&r-exercises-1596733e91f3fb9c484b6822684539bc004e0aa4.tar.gz | |
5.7
Diffstat (limited to '5')
| -rw-r--r-- | 5/7.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -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); |
