#ifndef FIXEDSTRING_H // see page 96 for explanation
#define FIXEDSTRING_H
#include <iostream.h>
#include <iomanip.h>
const int MaxSize = 256;  // Maximum allowable string size

class FixedString {
	
	friend bool operator <(const FixedString & s1,
		const FixedString & s2);
	friend istream & operator >>( istream & inp,
		FixedString & s );
	friend ostream & operator <<( ostream & inp,
		const FixedString & s );
	
public:
	FixedString();
	FixedString( const char * s );
	FixedString( const FixedString & s );
private:
	char str[MaxSize+1];  // String characters
};
#endif
// FIXEDSTRING.CPP - FixedString member function definitions
// Fixed-length string class: allocate 256 characters for every string
// Makes strings first class objects: Version 1
// Construct from C-style strings 
// or by Copying another FixedString Object
// Overload I/O operators

#include "fixedString.h" 
#include <string.h> // build on C-style strings

//######### define friends first

bool operator <(const FixedString & s1,
	  const FixedString & s2)
{
	if(strcmp(s1.str,s2.str) < 0)
		return true;
	else
		return false;
}


istream & operator >>( istream & inp, FixedString & s )
{
	inp.get(s.str,MaxSize+1,'\n');
	inp.ignore(1000,'\n'); // skip to end of line
	return inp;
}


ostream & operator <<( ostream & outp, const FixedString & s )
{
	outp << s.str;
	return outp;
}


//####### define member functions
FixedString::FixedString()
{
	str[0] = '\0';
}

FixedString::FixedString( const char * s )
{
	strncpy(str,s,MaxSize);
	str[MaxSize] = '\0'; // in case "s" is too big
}

FixedString::FixedString( const FixedString & s )
{
	strncpy(str, s.str, MaxSize);
	str[MaxSize] = '\0'; // in case "s" is too big
	//- should never happen but who knows?
}