- Does this mean that the program should no longer be constrained by the MAXLINE string limitation?
No, it doesn't. At this point in the book, you're not supposed to know how to handle and store lines with an arbitrary length. Chapter 1 is a very superficial introduction to C, it is not expected that you redesign the whole code.
With that in mind: the exercise is asking you to print as much as you can of the line, i.e., if the line is longer than MAXLINE
characters, you just print the first MAXLINE
. But you should also print the length of the original line. In other words, you store as much as you can up to MAXLINE
characters, but you keep reading after that limit just for the purpose of counting.
To do this, the getline()
function must be updated to keep counting the chars until the end of line, even if it reached the limit of the buffer, in which case it counts but it
obviously doesn't write the text to the buffer.