I'm having problems having a program read data input from a txt file, putting in a linked list, and then outputting the information into a different txt file.
//**********************************************
//* Add an item to the head of the linked list *
//**********************************************
void Inventory::InsertItem( int InitProductIDNumber, int InitManufacturerIDNumber, double InitWholesalePrice,
double InitMarkUpPercentage, char InitProductDescription[], int InitQuantityInStock,
Inventory* CurrentRecordPointer )
{
Inventory* CurrentPointer;
Inventory* TrailPointer;
bool Found;
//*********************************************************
//* First Case: The list is empty. The node containing *
//* the new item is the only node and thus the first node *
//* in the list. *
//*********************************************************
if( FirstRecordPointer == NULL )
{
FirstRecordPointer = CurrentRecordPointer;
}
else
{
CurrentPointer = FirstRecordPointer;
Found = false;
//*****************************************************
//* Second Case: The new item is smaller than the *
//* smallest item in the list. The new item goes at *
//* the beginning of the list and the head pointer is *
//* adjusted. *
//*****************************************************
if( CurrentPointer == FirstRecordPointer )
{
NextRecordPointer = FirstRecordPointer;
FirstRecordPointer = CurrentRecordPointer;
}
//****************************************************
//* Third Case: The new item is to be inserted *
//* within the list. If the item is larger than all *
//* items in the list, it is inserted at the end of *
//* the list. Thus, the value of *
//* "CurrentPointer" is NULL and the new item *
//* is inserted after "TrailPointer." If the item is *
//* to be inserted somewhere in the middle of the *
//* list, the new item is inserted between *
//* "TrailPointer" and "CurrentPointer." *
//****************************************************
else
{
TrailPointer->NextRecordPointer = CurrentRecordPointer;
NextRecordPointer = CurrentPointer;
}
}
}
//************************************************
//* Count the number of items in the linked list *
//************************************************
int Inventory::CountItems( )
{
Inventory* CurrentRecordPointer;
int ItemCounter = 0;
//**********************************************************
//* Records are listed until the NULL value is encountered *
//**********************************************************
CurrentRecordPointer = FirstRecordPointer;
while( CurrentRecordPointer !=NULL )
{
OutputFile << endl;
OutputFile << right;
OutputFile << endl << setw(15) << setfill(' ')
<< CurrentRecordPointer->GetProductIDNumber( );
OutputFile << setw(15) << setfill(' ')
<< CurrentRecordPointer->GetManufacturerIDNumber( );
OutputFile << setw(35) << setfill(' ')
<< CurrentRecordPointer->GetProductDescription( );
OutputFile << fixed << showpoint << setprecision(2) << setw(15) << setfill(' ') << " $ "
<< CurrentRecordPointer->GetWholesalePrice( );
OutputFile << setw(10) << setfill(' ')
<< CurrentRecordPointer->GetMarkUpPercentage( );
OutputFile << "The Number Of Items In The List: " << ItemCounter;
CurrentRecordPointer = CurrentRecordPointer->GetLink( );
}
OutputFile << endl << Separator << endl;
OutputFile.close( );
return;
}
//*************************************************
//* Return the value of the private class members *
//*************************************************
int Inventory::GetProductIDNumber( ) const
{
return( ProductIDNumber );
}
int Inventory::GetManufacturerIDNumber( ) const
{
return( ManufacturerIDNumber );
}
//**********************************************
//* Set the value of the private class members *
//**********************************************
void Inventory::SetProductIDNumber( int InitProductIDNumber )
{
ProductIDNumber = InitProductIDNumber;
}
void Inventory::SetManufacturerIDNumber( int InitManufacturerIDNumber )
{
ManufacturerIDNumber = InitManufacturerIDNumber;
}
I'm sorry but it doesn't seem like you're serious about getting help. Your header file, main(), input file – all are missing and we have to keep asking you for every bit of information at each stage. If you rally want help please spend some time drafting a thoughtful, self-contained post instead of dumping anything that comes to hand. Think what pieces of information anybody who attempts to help you will need and try and address those as much as possible to start with rather than wasting time going back and forth. Or maybe someone more perspicacious can discern your problem(s)