Confused on what it is telling me

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


#include <string>
#include <iomanip>
#include <iostream>
#include <fstream>
using namespace std;

/*
This program is made by Skyler Peterson and will request the current user a sale's persons name and
to accumulate the total sales and count the number of sales staff, compute the average sales for all of the staff and
determine the salesperson with the highest sales amount.
*/

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
for (ctr = 0; ctr < SIZE; ctr++)
{
cout << "Enter sales persons name:";
getline(cin, salesPersonName[SIZE]);
if (cin.eof())
break;
Nopeople++;

cout << "Enter sales amount:";
cin >> salesAmount[SIZE];
}



//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");
}
It looks like you're accessing your arrays out of bounds. You have defined your arrays with a size of SIZE. When you try to access an array as array[SIZE] you access the array out of bounds. Remember arrays in C++ start at zero and end at SIZE - 1.

By the way please use code tags when posting code.

Topic archived. No new replies allowed.