Discussion 3-16

Today we did file input/output examples.

  1. fileIO.cpp has the test code we created while explaining the basic syntax/usage for ifstream and ofstream objects.
  2. sherlock.cpp shows an application: I recently read the complete Sherlock Holmes stories and I thought the author was a weirdo for using the word "singular" way too often. To test whether I was just crazy, we wrote this program to look through the stories (available in public domain; we easily found this file on the Internet during class) and count occurrences of "singular". Then we could compare against the "normal" frequency of the word "singular", as measured by going to WolframAlpha and typing "word frequency singular". Always fun when a little coding ability lets us settle the random questions that come up in everyday life!