Hello, I'm studying C++ by two months using the book : programming principles and practice using C++, I'm on chapter 5 now studying error reporting. The author in this chapter uses this example to show to the readers the run time errors :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include "std_lib_facilities.h"
int area(int length, int width)
{
return length*width;
}
int framed_area(int x, int y)
{
return area(x - 2, y - 2);
}
int main()
{
int x = -1;
int y = 2;
int z = 4;
int area1 = area(x, y);
int area2 = framed_area(1, z);
int area3 = framed_area(y, z);
}
|
this code produces a run-time error due to the division of area1 with 0.
Subsequently, the author introduces a facilitation contained in the header file which he wrote called error (). My problem is that when this function call should produces a system error over a string literal that we passed as an argument to the function, instead my program code at runtime produces a screen that reports:
>> Microsoft visual C++ runtime library
>> debug error!
>> program:..dio
>> 2013\Projects\learnprogramming\Debug\learnprogramming.exe
>> abort() has been called
What could be happened ? is this a problem of the function implementation ?
Here is the link of the page where you can read the header file containing the error() function :
http://www.stroustrup.com/Programming/PPP2code/std_lib_facilities.h