#include <fstream> #include <iostream> #include <iomanip> #include <cmath> #include <string> using namespace std; const int MAX_COMP = 50; const int MAX_MANU = 50; const int MAX_PRICE = 50; struct Computer { string Model; string Manu; int Price; string ARRAY1[100]; string ARRAY2[100]; int ARRAY3[100]; }; struct Database { Computer DB[MAX_COMP][MAX_MANU][MAX_PRICE]; }; void getComputer(Computer&, ifstream&, ofstream&, Database&); //void sortComputer(int ARRAY3[], int size); int main() { Computer data; Database base; ifstream iFile; ofstream oFile; iFile.open("CompSys.txt"); oFile.open("CompLog.txt"); getComputer(data, iFile, oFile, base); iFile.close(); oFile.close(); return 0; } void getComputer(Computer& data, ifstream& iFile, ofstream& oFile, Database& base) { int Idx = 0; while(!iFile.eof()&& Idx<100) { getline(iFile, data.Model, '\t'); data.ARRAY1[Idx] = data.Model; getline(iFile, data.Manu, '\t'); data.ARRAY2[Idx] = data.Manu; iFile >> data.Price; data.ARRAY3[Idx] = data.Price; Idx++; base.DB[data.ARRAY1[Idx]][data.ARRAY2[Idx]][data.ARRAY3[Idx]]; //Line # 71 } cout<<data.ARRAY1[0]<<" "<<data.ARRAY2[0]<<" "<<data.ARRAY3[0]; }
struct
Computer
Database
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)