I am currently studying the well-known book for C - The C Programming Language, 2Ed. And when I trying the code in P.29, I think there is something wrong in the getline function:

```
int getline(char s[], int lim) {
    int c, i;

    for (i=0; i<lim-1 && (c=getchar()) != EOF && c!='\n'; i++)
        s[i] = c;
    if (c == '\n') {
        s[i] = c;
        i++;
    }

    s[i] = '\0';
    return i;
}

```

What if when the for loop ended, `i == lim-1` and `c == '\n'`? In this case, I think the array would be out of boundary, since `s[lim]` would be set to '\0'.

Does anyone think this is wrong? Thanks for your help.