Like Tree1Likes
  • 1 Post By MK27

One more Debug Assertion Failed! Error

This is a discussion on One more Debug Assertion Failed! Error within the C Programming forums, part of the General Programming Boards category; What's with That error? I couldn't get rid of it. As long as my codes increase, The chance of getting ...

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    19

    One more Debug Assertion Failed! Error

    What's with That error? I couldn't get rid of it. As long as my codes increase, The chance of getting that error increasing as well.

    The same error;

    file:.....\istype.c
    Line: 56 and then 68 (Always both line)

    Expressionunsigned)(c+1)<=256

    It seems that I assigned an element whose ASCII number exceeds 256 into a char variable. At least, I think so.

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,625
    Can you post the relevant code that caused this error?
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    19
    I don't know which piece of code caused. From very beginning of programming, when I receive that error, I always receive on line 56 and 68, however these lines changed so many times. I think these lines doesn't indicate my codes, maybe it caused in ctype library?

    Moreover, if you want all of my codes, I don't suggest it, because it has 414 lines of codes.

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    You: I think the error is between 56-68.
    Someone else: So how do you expect us to fix it? Post the code!
    You: I don't know which line it's on! It must be a problem with a standard header file that works for literally everyone else.

    ^^ Seriously, what kind of logic is that? Again, post all the relevant code. That means everything around, between, and leading up to where you got the error.

  5. #5
    Registered User
    Join Date
    Mar 2012
    Posts
    19
    If I assign NULL to all elements of a Char array, does it make any problem?
    char a[0]=NULL a[1]=NULL .....

  6. #6
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,625
    Can you make another smaller source code that causes the same error?
    Devoted my life to programming...

  7. #7
    Registered User
    Join Date
    Mar 2012
    Posts
    19
    Code:
     #define kerem 982721*11
     
    int main(){
    
    char isl[61],cossm[61],sinn[51];
    double isl2[61]={0.0},isl3[51]={0.0},output[51]={0},input[51]={-kerem},coss2[61]={0.0},postfix[51]={0},flo=0.0,cosislem[51]={1};
    int i=0,bas=0,i2=0,var=0,i3=0,girdi=0,nokta=0,baskon=0,noktakontrol[50]={0},nk=0,girdinok=0,n=0,k=0,eksikontrol[50];
    int sayi=0,ek=0,eksivar=0,n1=0,i1=0,ce=0;
    printf("Bir matematik islemi giriniz: ");
    gets_s(isl);
    
    for(i=0;i<50;i++)
    {noktakontrol[i]=1;eksikontrol[i]=1;cosislem[i]=1;}
    for(i=0;i<50;i++)
    {output[i]=kerem;}
    for(i=0;i<51;i++)
    {cossm[i]=NULL;sinn[i]=NULL;}
    for(i=0;i<60;i++)
    {
    if(isl[i]==NULL)break;
    elseif(isdigit(isl[i])){sayi=1;}
    elseif(!isdigit(isl[i]) && isl[i]!='c' && isl[i]!='o' && isl[i]!='s' && isl[i]!='['){if(sayi==1){ce++;sayi=0;}}
    elseif(isl[i]=='c' && isl[i+3]=='['){n=i+4;k=0;while(isl[n]!=']'){cossm[k]=isl[n];k++;n++;};cossm[k]='=';isl[i]='1';cosislem[ce]=cos(cosinus(cossm));ce++;i=n+1;for(i=0;i<51;i++)
    {cossm[i]=NULL;}}
    }
    for(i=0;i<60;i++)
    { 
    if(isl[i]=='c'){n=i;for(n;n<60;n++){isl[n]=isl[n+1];}}
    }
    for(i=0;i<60;i++)
    { 
    if(isl[i]=='o'){n=i;for(n;n<60;n++){isl[n]=isl[n+1];}}
    }
    for(i=0;i<60;i++)
    { 
    if(isl[i]=='s'){n=i;for(n;n<60;n++){isl[n]=isl[n+1];}}
    }
    for(i=0;i<60;i++)
    { 
    if(isl[i]=='['){isl[i]='.';i++;while(isl[i]!=']'){isl[i]='0';i++;}}
    }
    for(i=0;i<60;i++)
    { 
    if(isl[i]==']'){n=i;for(n;n<60;n++){isl[n]=isl[n+1];}}
    }
    

    Here is the piece of code that my cause that problem. The others work fine, functions do as well, so I did not write them here.
    Last edited by ilerleartik; 03-17-2012 at 05:46 PM.

  8. #8
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    Code:
    main.c: In function ‘main’:
    main.c:10: error: ‘kerem’ undeclared (first use in this function)
    main.c:10: error: (Each undeclared identifier is reported only once
    main.c:10: error: for each function it appears in.)
    main.c:14: warning: implicit declaration of function ‘gets_s’
    main.c:21: warning: assignment makes integer from pointer without a cast
    main.c:21: warning: assignment makes integer from pointer without a cast
    main.c:24: warning: comparison between pointer and integer
    main.c:25: warning: implicit declaration of function ‘elseif’
    main.c:25: warning: implicit declaration of function ‘isdigit’
    main.c:25: error: expected ‘;’ before ‘{’ token
    main.c:32: warning: statement with no effect
    main.c:36: warning: statement with no effect
    main.c:40: warning: statement with no effect
    main.c:45: error: expected declaration or statement at end of input
    main.c:12: warning: unused variable ‘ce’
    main.c:12: warning: unused variable ‘i1’
    main.c:12: warning: unused variable ‘n1’
    main.c:12: warning: unused variable ‘eksivar’
    main.c:12: warning: unused variable ‘ek’
    main.c:12: warning: unused variable ‘sayi’
    main.c:11: warning: unused variable ‘k’
    main.c:11: warning: unused variable ‘girdinok’
    main.c:11: warning: unused variable ‘nk’
    main.c:11: warning: unused variable ‘baskon’
    main.c:11: warning: unused variable ‘nokta’
    main.c:11: warning: unused variable ‘girdi’
    main.c:11: warning: unused variable ‘i3’
    main.c:11: warning: unused variable ‘var’
    main.c:11: warning: unused variable ‘i2’
    main.c:11: warning: unused variable ‘bas’
    main.c:10: warning: unused variable ‘flo’
    main.c:10: warning: unused variable ‘postfix’
    main.c:10: warning: unused variable ‘coss2’
    main.c:10: warning: unused variable ‘input’
    main.c:10: warning: unused variable ‘isl3’
    main.c:10: warning: unused variable ‘isl2’
    main.c:45: warning: control reaches end of non-void function
    Apart from being the messiest jumble of poorly indented crap I've ever tried to compile, it generates way more problems than you're reporting. The "unused variable" and "control reaches end" are simply because you don't have the rest of your function. Everything else needs to be tended to.

    And I'd be willing to bet that most of this would go away if you properly indented your code so you could clearly see where the missing syntax and malformed expressions are.

  9. #9
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by ilerleartik View Post
    Here is the piece of code that my cause that problem. The others work fine, functions do as well, so I did not write them here.
    When you cut and paste into code tags, cut and paste as plain text; there should be an option for this in some menu of the application you cut from. Find it and edit that post or I doubt anyone will want to read the mess.

    If the indentation actually looks the same way in your editor or whatever, fix that first too. You cannot program that way, or at least, you cannot program that way and expect other people to look at your code.
    Salem likes this.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debug Assertion Failed error
    By frankchester in forum C Programming
    Replies: 7
    Last Post: 12-02-2010, 09:55 AM
  2. error "debug assertion failed"
    By roaan in forum C Programming
    Replies: 26
    Last Post: 08-07-2009, 01:36 PM
  3. debug assertion failed
    By rahulsk1947 in forum C++ Programming
    Replies: 7
    Last Post: 06-14-2009, 04:36 PM
  4. debug assertion failed!
    By chintugavali in forum C++ Programming
    Replies: 5
    Last Post: 12-21-2007, 04:05 AM
  5. debug assertion failed?!?
    By ichijoji in forum C++ Programming
    Replies: 3
    Last Post: 08-30-2003, 04:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21