// readNames4.cc read names from a file with both first and last names
// print the length of every name

// P. Conrad for CISC181 06S   02/17/06

#include <iostream>
#include <fstream>

using namespace std;

// following line of code changes every instance of NAMELEN
// to be 32

// the terminology for such a line is
//    #define constant
//    more generally, anything that starts with # is a pre-processor directive

// 

#define NAMELEN 32

#define INPUT_FILENAME "fullNames.dat"

int main(void)
{
  
  ifstream infile(INPUT_FILENAME, ios::in);

  if (!infile)
    {
      cerr << "Could not open " << INPUT_FILENAME << endl; // !??!?
      exit(1);
    }

  char name[NAMELEN];

  // where infile >> name; reads character until it hits white space,
  // and skips over white space, infile.getline(name,NAMELEN) reads an
  // entire line, until a \n  (and it skips over the \n)


  infile.getline(name, NAMELEN);
  
  while (!infile.eof() )
    {

      // process the name

      int length = strlen(name);
      cout << "The length of the name " << name << " is " << length << endl;

      // try to read the next name

      infile.getline(name, NAMELEN);
    }

  infile.close(); // close the file when we are done with it

  return 0; // successful completion.

}





