Dave's Brain

Browse - Programming Tips - Why is my program getting this debug assertion failed:

Date: 2010nov25
Language: C++
Product: Visual C++

Q.  Why is my program getting this debug assertion failed:

Debug Assertion failed! File: isctype.c Line: 56 Expression:(unsigned)(c+1) <= 256
A. Probably because you are reading beyond your buffer. This isn't a problem with VC++ ... it is helping you out. For example this will cause this problem:
char buf[] = "abc"; for (char *p = buf;;p++) // Loop forever (bug on purpose) { if (isalnum(*p)) printf("alnum"); }
As you can see this faulty code will do isalnum(buf[5]) which is beyond what we have allocated. isalnum() or isdigit() or other is* function will assert letting us know.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.