Sunday, August 2, 2009

When loading a file in c++ how can i return an array of structures, from the load function to the main?

struct RecDetails LoadRecords(int %26amp;NumRecs)


{


struct RecDetails Quotes[MAX_QUOTES];





ifstream InFile;


int i = 0;





InFile.open("Test.txt");





while(!InFile.eof())


{


InFile %26gt;%26gt; Quotes[i].QuoteNum;


InFile.getline(Quotes[i].Name, BUFF_LEN);


InFile %26gt;%26gt; Quotes[i].Cost;


InFile %26gt;%26gt; Quotes[i].DeliveryCharge;


InFile %26gt;%26gt; Quotes[i].GuaranteePeriod;


i++;


}





InFile.close();





NumRecs = i;


return Quotes;


}











...








then in main::





struct RecDetails Quote;


struct RecDetails Quotes[MAX_QUOTES];





Quotes = LoadRecords(NumRecs);








keeps appearing with E2034 cannot convert 'RecDetails' to 'RecDetails' errors,





any help people?





If can help on msn or somethin, jimmyhigg@hotmail.co.uk, ill be about finishing this assignment for the next week no doubt...

When loading a file in c++ how can i return an array of structures, from the load function to the main?
don't have a clue to your question, just felt sorry for you cos no-one had answered your question and i didn't want you to feel left out.


No comments:

Post a Comment