Here is my dilemma, I have a snippet of code that I have written to extract data from a file and print it to the screen. It works well.
But now I want to only display lines of the file based on certain
column values in the text. In other words, each line in the file has
29 columns broken down into 5 for an ID, 15 for a name, 3 for a qty, 3for a reorder point, and 3 for the order size.
When the qty columns drop below that of the reorder point I would like to print that to the screen. I am new to C++ and have read the fstream txt's and others I am lost.
Here is my code and file I am pullingfrom. Thanks in advance.
// reading the stock.dat file
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
int main()
{
char buffer [256];
ifstream stock ("stock.dat");
if (! stock.is_open())
{
cout << "Error opening file";
exit (1);
}
while (! stock.eof() )
{
stock.getline (buffer,100);
cout << buffer << endl;
} return 0;
}
- Contents of stock.dat file -
BKT01Prunes 015020025
BKT05Pears 032020025
BKT07Peaches 011020025



LinkBack URL
About LinkBacks


