i keep getting that error everytime. (error C2106: '=' : left operand must be l-value) i want to take specific feilds from the data i read in, and put it into another struct. but when i get to the productlineid it keeps erroring. both are set to char of [10]
here's what im doing
Code:class Data //class used to take in the data from the file { private: struct Rawdata { int ordernumber; char date[10]; int orderedproductid; float priceperproduct; int numberordered; char productlineid[10]; //data in this field must be 10 chars long so ----'s are added to the text int customerid; }; // file so each product id has 10 chars so it properly reads it public: Data( ); //constructor void ReadFile(int); ifstream transactionin; // Allows class access to tranaction file }; class Report //class used to sort the data and print it out { public: struct Transaction // Declaration of Transaction Structure { int orderedproductid; int numberordered; float priceperproduct; char productlineid[10]; //data in this field must be 10 chars long so ----'s are added to the text }; // file so each product id has 10 chars so it properly reads it Transaction datain[10]; Report(); //constructor void SortData(); void PrintData(); }; .............cut out not relevent code void Data::ReadFile(int MAXRECS) { int Record = 0; transactionin.open("transaction.h", ios::in, ios::nocreate); //open transaction.h file if (transactionin == NULL) //check if file opened correctly { cout << "\nThe file transaction.h was not opened, please check the file" << endl; exit(1); } int LINECOUNTER = 0; //counter to increase the structure char NEWLINE = '\n'; int ch; char line[100]; while( (ch = transactionin.peek()) != EOF) // this counts how many lines are { // in the transaction.h data file transactionin.getline(line,100,NEWLINE); LINECOUNTER++; } transactionin.close(); Rawdata record[10]; // constant problem!!!!!!! transactionin.open("transaction.h", ios::in, ios::nocreate); while (Record < LINECOUNTER) //reads the text file until MAXRECS has been reached { // putting the data into the appropriate struct array position transactionin >> record[Record].ordernumber; transactionin >> record[Record].date ; transactionin >> record[Record].orderedproductid ; transactionin >> record[Record].priceperproduct ; transactionin >> record[Record].numberordered; transactionin >> record[Record].productlineid ; transactionin >> record[Record].customerid ; Record++; // increment the record counter } transactionin.close(); //close the data file transaction.h Record=0; Report::Transaction datain[10]; while(Record < LINECOUNTER) { datain[Record].orderedproductid = record[Record].orderedproductid; datain[Record].numberordered = record[Record].numberordered ; datain[Record].priceperproduct = record[Record].priceperproduct; datain[Record].productlineid = record[Record].productlineid ; //THIS IS WHERE ERRROR HAPPENS Record++; } }



LinkBack URL
About LinkBacks


