Saturday 16 March 2013

assert a debugging tool


int i,j;
    for(i=0;i<=10;i++)
    {
    j+=5;
    assert(i<5);
    }
Answer:
Runtime error: Abnormal program termination.
             assert failed (i<5), <file name>,<line number>
Explanation:
asserts are used during debugging to make sure that certain conditions are satisfied. If assertion fails, the program will terminate reporting the same. After debugging use,
    #undef NDEBUG
and this will disable all the assertions from the source code. Assertion
is a good debugging tool to make use of. 

Blog Author: Vijay Kumar

Go to: Java Aptitude

No comments:

Post a Comment