When you run it, it should show you the text in the first two lines of the file. If either line has more than 24 characters, then it cuts that line off at 24 characters.
That's what I expected. What I didn't expect is that, if the first line gets cut off, the second line displays nothing at all. Why is this?
Turns out that if I add in.clear(); between the commands, then the second line finishes up by displaying what the first didn't have room for. No part of the second line of the file is displayed.
Check this out. Enter "asdf" hit enter, then enter "1234" and hit enter again. Then run it again and enter "asdf1234" in one line and hit enter. The thing is that when getline(str,n) extracts n characters (including '\0') the failbit is set. Clearing the stream's status will work, but mind that the stream's buffer is as you left it...