# Debug Assertion Failed



## -Mark03- (Apr 7, 2005)

> #include <iostream>
> #include <fstream>
> #include <iomanip>
> #include <ctype.h>
> ...





> Debug Assertion Failed!
> Program: path to file
> File:isctype.c
> Line:56
> ...


I dunno what this means or whats causing it. Could someone explain?


----------



## codejockey (Feb 11, 2002)

An assertion is a special type of statement that validates assumptions or checks conditions in code; if the assertion fails, it means that the condition or assumption was false. The programmer adds assertions (typically near the beginning of a function/method) to trap conditions that might cause the function to execute incorrectly. For example, a programmer might add an assertion at the the beginning of a function that performs division to test that any parameter used as a divisor was not zero, since division by zero is undefined. In your example, the statement:

Expression: (unsigned)(c+1) <=256

means that (c+1) was expected to be <= 256. The programmer probably coded something like:

assert (c+1 <= 256)

and when the assertion was checked, it failed (i.e., c has a value of at least 255). If your program was intended to work with characters (max 8 bits = 1 byte), then the highest character value should be 255. If c were declared as an integer, then it could have values greater than 255, which may be part of the problem. The bottom line, however, is that in your example, (c+1) was expected ("asserted") to be less than or equal to 256, and during program execution, c had a value that was greater than 255.

Hope this helps.


----------



## -Mark03- (Apr 7, 2005)

Thanks


----------

