// Start to the solution to Checkpoints 2 and 3 of Lab 8.

#include <algorithm>
#include <cctype>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <string>
#include <vector>

//  Constants and typedefs.  Used to make the code more readable.

const int MIN_WORD_SIZE = 4;
const int MAX_WORD_DISTANCE = 3;
typedef std::map< std::string, std::list< std::string> > NearbyMapType;
typedef NearbyMapType::iterator NearbyMapIteratorType;


//  Break up a string into a vector of strings of consecutive
//  lower-case letters.
std::vector< std::string >
breakup_line( std::string const& line )
{
  std::vector< std::string > words;
  std::string one_word;
  int i=0;

  //  Search for start of next word.
  while ( i < line.size() )
  {
    if ( isalpha(line[i]) )
    {
      //  Add letters to the word, one at a time, until the end of
      //  the line or a non-alphabetic character is reached.
      one_word.clear();
      one_word.push_back( tolower( line[i] ) );
      for ( ++i; i < line.size() && isalpha( line[i] ); ++i )
        one_word.push_back( tolower( line[i] ) );
      words.push_back( one_word );
    }
    ++i;
  }
  return words;
}


int main( int argc, char* argv[] )
{
  //  Check the number of arguments
  if ( argc != 3 )
    {
      std::cerr << "Usage:  " << argv[0] << " infile outfile\n";
      return 1;
    }

  //  Open the input stream.
  std::ifstream text_str( argv[1] );
  if ( !text_str )
    {
      std::cerr << "Could not open " << argv[1] << " to read.\n";
      return 1;
    }

  //  Open and check the output file
  std::ofstream out_str( argv[2] );
  if ( !out_str )
    {
      std::cerr << "Could not open " << argv[2] << " for output.\n";
      return 1;
    }


  return 0;
}

