// ARRAYTBL.CPP #ifndef __ARRAYTBL_CPP #define __ARRAYTBL_CPP #include "arraytbl.h" #include #include #include /////////////////////////////////////////////////////////////// ArrayTable::ArrayTable() { Index = 0; // INITILIZE TO SHOW AN EMPTY ARRAY int i; for( i=0; i<256; i++ ) Table[ i ][ 0 ] = '\0'; } inline ArrayTable::~ArrayTable() { ; } int ArrayTable::Add( char *str ) { // RETURN MEMORY LOCATION Index++; if( Index > 255 ) { cout << "\n ERROR !, ARRAY TABLE FULL \n"; exit( 1 ); } strcpy( Table[ Index ], str ); Table[ Index ][ 40 ] = '\0'; return( Index ); } int ArrayTable::Delete( int MemLoc ) { // RETURN 1 IF DELETED, 0 IF NOT if( Table[ MemLoc ] == '\0' ) // STRING MUST BE NULL return( 0 ); else { Table[ MemLoc ][ 0 ] = '\0'; return( 1 ); } } char *ArrayTable::Get( int MemLoc ) { // RETURN POINTER TO STRING, NULL IF NOT FOUND return( Table[ MemLoc ] ); } void ArrayTable::Print( int MemLoc ) { if( strcmp( Table[ MemLoc ], "\\n" ) == 0 ) cout << "\n"; else cout << Table[ MemLoc ]; } void ArrayTable::PrintAll( void ) { cout << "\n MEM-LOC \t VALUE \n---------------------------------------\n"; int i; for( i=0; i<256; i++ ) { if( Table[ i ][ 0 ] != '\0' ) { cout << " " << i << "\t\t\"" << Table[ i ] << "\"\n" ; } } cout << "\n"; } ///////////////////////////////////////////////////////////////////////////// #endif // __ARRAYTBL_CPP