can anybody help me get a input file to input number data one line at a time and then output it to a output file. it reads the data but does not stop and move to another line. I need the data to stop after the first full line and then start on the second.
Code:
int main()
{
/******************************************************************************
outputs the file
************************************************************************/
ifstream fin;
ofstream fout;
/*********************************************************************
gives the array a variable name
******************************************************************/
lref head;
head = NULL;
lref end;
lref tail;
end = new Node;
if (head == NULL)
{
head = end;
}
else
{
tail= end;
end->next = new Node;
}
fin.open("input.txt"); //opens the input file
if (fin.fail())
{
cout <<"Input file failed." << endl;
exit(1);
}
fout.open("outs.txt"); //opens the output file
if (fout.fail()) // will output a error if the output file fails
{
cout << "Output file failed." << endl;
exit(1);
}
/**********************************************************
gives the decimal point and sets it to 2
******************************************************/
fout.setf(ios::fixed);
fout.setf(ios::showpoint);
fout.precision(2);
/***********************************************************
outputs the average and total info to the output file for display
**************************************************************/
fout << "January" <<setw(15) << "February" << setw(15) << "March" << setw(15) << "Average" << endl;
do
{
TotalSales sum(lref& head);
fin >> head->data;
fout <<head->data << setw(15);
}
while (! fin.eof());
fin.close();
fout.close(); //closes the output file
delete head, end, tail;
system("pause"); // pauses the screen after the program runs
return 0;
}