[Ilugc] how to send EOF

  • From: rajasuperman@xxxxxxxxx (Raja Subramanian)
  • Date: Tue, 1 Mar 2011 10:31:30 +0530

On Mon, Feb 28, 2011 at 7:38 AM, Kenneth Gonsalves
<lawgon at thenilgiris.com> wrote:

this is one of the examples in K&R

In my college days, counting lines was used as an example to
demonstrate the difficultly of writing Software Requirements Specs.
Even for a simple line counting program, the SRS becomes
unexpectedly complicated as one starts considering the boundary
cases.

If SRS is defined as "count all new line chars in the file", then what
about files which do not end with a new line character on the last line?

If we then modify the spec as "count all new line chars in the
file, and EOF unless preceded by a new line", then what about
files which have no text, only a single EOF char.  Is that considered
as a file with 0 lines or with 1 line.

Interesting exercise for any developer creating requirement specs.

- Raja

Other related posts: