What does this mean

Exception thrown: write access violation.

_Left was 0xCCCCCCCC.

If there is a handler for this exception, the program may be safely continued. What does this mean and how do i fix my code?

int main()
{
const int SIZE = 25;
int Nopeople = 0;
double salesAmount[SIZE];
string salesPersonName[SIZE];
int ctr=0;
ofstream fout("sales.fil");

if (!fout.is_open());
{
cout << "problem opening file." << endl;
system("pause");
exit(-1);
}
fout << fixed << setprecision(4);


//housekeeping


//input
cout << "Enter sales persons name:";
getline(cin, salesPersonName[SIZE]);
cout << "Enter sales amount:";
cin >> salesAmount[SIZE];

Nopeople++;



//processing



//output
fout << setw(15) << left << "Name"
<< setw(15) << right << "Sales Amount" << endl;

fout << setw(20) << left << salesPersonName;
fout << setw(20) << right << salesAmount;
fout << "Number of sales people" << Nopeople;




cout << "Program ended successfully" << endl;
system("type sales.fil");
system("pause");
}
Last edited on
Remove the semicolon at the end of the if (!fout.is_open()) line.

1
2
3
4
5
6
if (!fout.is_open());
{
cout << "problem opening file." << endl;
system("pause");
exit(-1);
}
thanks wildblue but now im getting this before it even opens in console

Exception thrown: write access violation.

_Left was 0xCCCCCCCC.

If there is a handler for this exception, the program may be safely continued.
Topic archived. No new replies allowed.