It states: Run-Time Check Failure#2 - Stack around the variable 'list' was corrupted. Can anyone help me figure this out? This program runs and it does what its supposed to do... I'm stumpt as to what I need to do.
#include <iostream>
using namespace std;
int removeAt(int [], int, int);
int main ()
{
int list[7] = {5, 3, 6, 7, 1, 4, 2};
int y = 0;
int searchItem = 0;
int elements = 7;
bool found = false;
cout << "Here is the unsorted list: " << endl;
for (y = 0; y < 7; y++)
{
cout << list[y] << " ";
}
cout << endl;
cout << endl;
cout << "What number do you want to erase from the list?" <<endl;
cin >> searchItem;
for(y = 0; y < elements; y++)
{
if (list[y] == searchItem)
found = true;
}
if (found == true)
{
elements = removeAt(list, elements, searchItem);
cout << "Here is the list minus your number: ";
for(y = 0; y < elements; y++)
{
cout << list[y] << " ";
}