The overall program is a sort of sales system for a fictional carpet shop (thrilling I know), but it basically starts, reads customer details entered previously into an array of structures, the user can then input some more 'orders' and it will save it all out to a text file at the end.
I can write stuff out to text files fine, but my compiler seems to hate my read from file function. The debugger gives me this Access Violation error:
Project1.exe raised exception class EAccessViolation with message 'Access Violation at address 00402DBD. Write of address 00130008.' Process stopped. Use step or run to continue.
Then the debugger jumps into the istream function. When I comment out my read file function, the rest of the program works fine.
Here are the parts of my program that use this function:
struct RecDetails {
int QuoteNum, GuaranteePeriod;
char Name[NAME_LEN];
float Cost, DeliveryCharge;
}; // structure which declares my array type
RecDetails ReadRecords(RecDetails Quotes[MAX_QUOTES],int MaxQuotes); // Function prototype
RecDetails Quotes[50]; // Array of structures
ReadRecords(Quotes, MaxQuotes); // Function call in main
RecDetails ReadRecords(RecDetails Quotes[MAX_QUOTES], int MaxQuotes)
{
ifstream InputFile;
int I = 0;
InputFile.open("quotes.txt");
while(!InputFile.eof())
{
InputFile >> Quotes[I].QuoteNum;
InputFile.getline(Quotes[I].Name,NAME_LEN);
InputFile >> Quotes[I].Cost;
InputFile >> Quotes[I].DeliveryCharge;
InputFile >> Quotes[I].GuaranteePeriod;
I++;
}
InputFile.close();
MaxQuotes = I;
return Quotes[MAX_QUOTES];
} // The function itself
As I said, when I comment out the function and the function call, the rest of it works fine, so the problem must be something to do with my ReadRecords function, I just can't figure out what's wrong with it. Any help would be appreciated

New Topic/Question
Reply




MultiQuote




|