Ok so this is what i have now in main
Code:
#include "inventory.txt"
#include "myfile.h"
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
struct Item myArray[Max];
read( myArray, Max, "inventory.txt");
in my header file
Code:
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
const int Max=100;
struct Item
{
string ID;
int sold;
int rem;
};
void read(Item Itemlist[], int length, string filename)
{
std::ifstream infile("filename.txt");
std::ofstream outfile("filename.txt");
infile.open("filename");
for(int i=0; i<length; i++)
{
infile >> Itemlist[i].ID;
cin.ignore(100, ' ');
infile >> Itemlist[i].sold;
cin.ignore(100, ' ');
infile >> Itemlist[i].rem;
}
return;
}
and my text file im trying to read from
Code:
619847GBE 641 998
418712IMB 107 867
227451GEM 789 181
981836KEA 747 171
986516IGU 303 71
501024BMU 895 743
455559SKK 764 234
706756EUU 687 730
500635MIS 841 670
341955IUS 32 907
791357GEK 391 284
etc
Im getting this error for every line in my text file
error C2059: syntax error : 'bad suffix on number'