/****************************************************************************
*  Program #1    Programmers: Dominic Veit      Date: Sept 3,1997
*                             Jeremy Haines
*
*  This program will parse a line of input into city, state and 
*  zipcode.  Library functions strcpy(), strlen(), and strncpy()
*  cannot be used and must be rewritten.
*
****************************************************************************/


#include <iostream.h>
#include <conio.h>
#include <ctype.h>
#include <fstream.h>

#define TRUE        (1==1)
#define FALSE       (0==1)

//function prototypes
int   main          (void);
void str_cpy( /*out*/ char * to_there,
              /*in*/  char * from_here);
/* This function copies characters from_here to_there :)
 * PRE: to_there is a string of sufficient length to hold from_here
 *      from_here is NULL terminated
 * POST: to_there will contain an array of char indentical to from_here
 *************************************************************************/
int str_len  ( /*in*/ char * string);
/* This function returns the number of characters in string
 * PRE   * string is NULL terminated.
 * POST: * to_there will contain an array of char indentical to from_here
 *         up to how_many characters.
 *************************************************************************/
void str_n_cpy( /*out*/ char * to_there,
                /*in*/  char * from_here,
                /*in*/  int    how_many  );
/* This function copies how_many characters from_here to_there :)
 * PRE:  * to_there is a string of sufficient length to hold how_many
 *         characters.
 *       * from_here is NULL terminated.
 * POST: * to_there will contain an array of char indentical to from_here
 *         up to how_many characters.
 *************************************************************************/
void zapWhiteSpace( /*in*/ char * string)
/*************************************************************************
 * This function removes spaces from the ends of string
 * PRE   * string is NULL terminated.
 * POST: * string will have no leading or trailing blanks
 *************************************************************************/

int main (void)
/*************/
   {
   char input_buffer[100]; //holds original input line from input file
   char city[50]; //Holds city portion of input line
   char state[50]; //Holds state portion of input line
   char zipcode[50]; //Holds zip code of input line
   int isCityParsed,isStateParsed,isZipParsed; //logical variable for error checking

   char * bufferpos = NULL; //pointer that is incremented along input string
   char * statepos  = NULL; //holds starting address of state
   char * zippos    = NULL; //holds starting address of zip code

   ifstream infile("infile.dat",ios::in); //input file
   ofstream outfile("outfile.dat",ios::out); //output file

      /* Code goes here */
   }


//FUNCTIONS

void str_cpy(char * to_there,
             char * from_here)
   {
      /* Code goes here */
   }

void str_n_cpy( /*out*/ char * to_there,
                /*in*/  char * from_here,
                /*in*/  int    how_many  )
   {
      /* Code goes here */
   }

int str_len  ( /*in*/ char * string)
   {
      /* Code goes here */
   }

void zapWhiteSpace( /*in*/ char * string)
   {
      /* Code goes here */
   }


OUTPUT FILE (outfile.dat)

Original input: 
Rolla, Missouri 65401
City: Rolla is 5 characters long.
State: Missouri is 8 characters long.
Zipcode: 65401 is 5 characters long.

Original input: 
Rolla,Missouri65401
City: Rolla is 5 characters long.
State: Missouri is 8 characters long.
Zipcode: 65401 is 5 characters long.

Original input: 
Rolla, Missouri 65401-1234
City: Rolla is 5 characters long.
State: Missouri is 8 characters long.
Zipcode: 65401-1234 is 10 characters long.

Original input: 
Rolla,Missouri65401-1234
City: Rolla is 5 characters long.
State: Missouri is 8 characters long.
Zipcode: 65401-1234 is 10 characters long.

Original input: 
Rolla  ,  Missouri    65401      
City: Rolla is 5 characters long.
State: Missouri is 8 characters long.
Zipcode: 65401 is 5 characters long.

Original input: 
New York City, New York    12345
City: New York City is 13 characters long.
State: New York is 8 characters long.
Zipcode: 12345 is 5 characters long.

Original input: 
     New York City  ,   New York   12345-4321     
City: New York City is 13 characters long.
State: New York is 8 characters long.
Zipcode: 12345-4321 is 10 characters long.


INPUT FILE (input.dat)

Rolla, Missouri 65401
Rolla,Missouri65401
Rolla, Missouri 65401-1234
Rolla,Missouri65401-1234
Rolla  ,  Missouri    65401      
New York City, New York    12345
     New York City  ,   New York   12345-4321