Hi ~
I am getting a strange RunTime Error while debugging my code.
Run-Time Check Failure #2 - Stack around the variable 'player' was corrupted.
Code is below. Would love some help on this one. Thanks.
ps ~ I realize that system("pause") is frowned upon but it is what we were taught to use to keep the console window open. I really just need the error addressed. Thanks Again!
#include<iostream>
#include<iomanip>
#include<cstring>
using namespace std;
const int NAME_LENGTH = 50;
struct Team
{
char name[NAME_LENGTH];
double playerNum;
double points;
};
int main()
{
const int NUM_PLAYERS = 5;
Team player[NUM_PLAYERS];
int index;
cout << "Enter player names, their numbers and points scored. \n\n";
for(index = 0; index <= 5; index++)
{
cout << "Enter name for player # " << (index + 1) << " : ";
cin.getline(player[index].name, NAME_LENGTH);
cout << "Enter Player Number for player # " << (index +1) << " : ";
cin >> player[index].playerNum;
}
system("pause");
return 0;
}