Hey, attempting to write a simple test building software, and keep running into a pointer error. I'm 100% sure its a problem with my use of the delete function, but I don't know how to fix it. I'll paste the code and the errors that valgrind gives. Thanks for your time :)
int main()
{
char name[] = "MA--A2--QF--IM\0";
Question * test = new Question[10];
char sep[] = "--";
for (int x = 0;x < 10;x++)
{
(test + x)->TestFunc();
}
//test->TestFunc();//GetInfo(name, sep);//don't worry about this
delete test;
}
valgrind error:
==9203== Invalid free() / delete / delete[]
==9203== at 0x4024851: operator delete(void*) (vg_replace_malloc.c:387)
==9203== by 0x8048988: main (in /media/HP V125W/TestBuilder/TestBuilder)
==9203== Address 0x42da02c is 4 bytes inside a block of size 204 alloc'd
==9203== at 0x402532E: operator new[](unsigned int) (vg_replace_malloc.c:299)
==9203== by 0x804889B: main (in /media/HP V125W/TestBuilder/TestBuilder)
==9203==