Author: Stan Eisenstat
Subject: Re: [Cs223] Number of Lines in a File in Stats.pl
Date: Saturday, 28 Mar 2020, 17:07:57
> Message Posted By: Unknown > > It seems like in stats.pl, the number of lines in a file is determined by > the number of newline characters. ... Corrext, since this is how the wc command counts lines. ===== > ... So a file with nine lines of text, but > no trailing newline, is treated as 8 lines in the calculations. However, > adding a newline at the end of the file causes the file to be treated as 9 > lines. ... Correct. ===== > ... If our program sorts under the limit when the file has the newline > character at the end (so that the number of lines in the calculation > matches up with the number lines of text), should we be worried if our > number of pushes/pops is too high when there is no newline at the end? No, since the only tests of efficiency use the file Hwk4/Tests/f8192, which has a trailing newline. The purpose of Hwk4/Stats.pl was to allow you to debug your code on smaller files. It was not intended to be robust (e.g., to handle files without newlines). --Stan-PREV INDEX NEXT