When I enter all the number in my C++ programme. Right before the output print out , the below statement will be show. A dbgheap code will be shown also and there is a lock beside the file name. And these are my code.
And I wanna ask how to end my programme when user enter -1 in the "Number of terms for the first polynomial:" statement I used the while/do-while below but It cannot run properly also.
Thanks!!! Windows has triggered a breakpoint in <Filename>.exe.
This may be due to a corruption of the heap, which indicates a bug in Lab5c2.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while Lab5c2.exe has focus.
The output window may have more diagnostic information.
int sizep = 0; // intialize to zero so if cin fails, it's within invalid bounds.
int sizeq = 0; // intialize to zero so if cin fails, it's within invalid bounds.
double* arrp = newdouble[sizep]; //a zero size array ¡¿?!
//...
cout << "Number of terms for the first polynomial p: ";
cin >> sizep;
cout << "Terms (from lowest order term to the highest):";
// get user guessing
for(int i= 0; i < sizep; i++){
cin >> arrp[i]; //arrp still is a zero size array ¡¿?!
}
Declare your arrays after you have their size from the user.
But make sure you don't have invalid value for size like -1 or 0.
1 2 3 4 5 6 7 8 9 10
while(sizep != -1){
cout << "Number of terms for the first polynomial p: ";
cin >> sizep;
double* arrp = newdouble[sizep];
//...
cout << "Number of terms for the first polynomial q: ";
cin >> sizeq;
double* arrq = newdouble[sizeq];