I was trying to see if my code for copying an array worked when I got this scary looking error message:
Debug Assertion failed!
Program: ...dio 2008\Projects\Test_Prep\Test_prep.exe
File: f:\dd\vctools\crt_bld\self_x86\srt\dbgdel.cpp
Line: 52
Expression _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
Here's my testing code and the function I wrote:
int main()
{
const int MAX_SIZE = 5;
int List[ MAX_SIZE ] = { 1, 2, 3 };
cout << List[ 2 ];
cout << endl << endl;
cout << *CopyArray( List , 5 );
HoldScreen();
}
int *CopyArray( int List[ ], int Size )
{
int NewSize = Size;
int *NewList = new int [Size];
for ( int Index = 0 ; Index < Size ; ++Index )
NewList[ Index ] = List[ Index ];
delete [] List;
List = NewList;
return NewList;
}
I think I'm messing up on the parameters in main?