The code in K&R looks correct to me as written. The copy function is only called on char arrays obtained from getline which properly null terminates the array. As pointed out, C style "strings" do not work if the null terminator is not present. If underlying assumptions are not valid in any context, nothing can be assumed to work. The text about malloc vs stack is both wrong and not relevant.