Thread: debug assertion failed!

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    78

    debug assertion failed!

    can anyone tell me why i am getting error while runtime

    Code:
    Section defGeometry::formSection( Side Section1,Section Section2,int N1,int N2,int N4,int NumberOfPoints )
    {defFile defG;
    //std::vector Sections FinalSection;
    int NoOfPoints,i,j,k;
    N1=2;
    N2=2;
    j=0;
    k=0;
    NoOfPoints=2*N1;
    struct Section defGeomSecTemp;
    struct point x;
    
    double defGeompt[3];
    
    for(i=0;i<N4;i++)
    {
    	for(j=NumberOfPoints-N2;j>=NumberOfPoints-N2;j++)
    	{
    		x.pt[0]=Section1.Sections[N4].Points[NumberOfPoints-N2].pt[0];
    		
    
    	}
    }		
    
    return  Section3;
    };

    error


    debug assertion failed!


    vector subscript out of range

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by chintugavali View Post
    can anyone tell me why i am getting error while runtime

    vector subscript out of range
    Perhaps it has to do with a vector subscript being out of range.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You have a vector with X elements, and you are trying to "use" elements beyond X.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Again, you should check your subscripts. I don't know what the actual cause of your problem is, because that code doesn't make any sense. I'm hoping and wishing that what you've posted is not, in fact, your actual code, because otherwise you've got a lot of things missing. In future, post actual code.

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    78

    Smile thanks!!

    Thanks experts! i have got the solution!! thank you very much!

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Code:
    Section defGeometry::formSection( Side Section1,Section Section2,int N1,int N2,int N4,int NumberOfPoints )
    {
    	defFile defG;
    	//std::vector Sections FinalSection;
    	int NoOfPoints,i,j,k;
    	N1=2;
    	N2=2;
    	j=0;
    	k=0;
    	NoOfPoints=2*N1;
    	struct Section defGeomSecTemp;
    	struct point x;
    
    	double defGeompt[3];
    
    	for(i=0;i<N4;i++)
    	{
    		for(j=NumberOfPoints-N2;j>=NumberOfPoints-N2;j++)
    		{
    			x.pt[0]=Section1.Sections[N4].Points[NumberOfPoints-N2].pt[0];
    		}
    	}
    
    	return  Section3;
    };
    Try indenting better next time. { are reserved for the {, so don't put any code there.
    Since a function is a block, indent all code inside it at least once.
    And typing "struct" before the struct name is not required in C++, so you can drop it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debug Assertion Failed!
    By IndioDoido in forum C Programming
    Replies: 31
    Last Post: 03-25-2008, 11:07 AM
  2. Visual Studio 2005 Debug Assertion Failed
    By natmas in forum C++ Programming
    Replies: 7
    Last Post: 07-17-2007, 04:28 PM
  3. debug assertion failed !
    By blue_gene in forum C++ Programming
    Replies: 2
    Last Post: 05-09-2004, 11:23 AM
  4. Debug Assertion Failed!
    By Ray Schmidt in forum C++ Programming
    Replies: 3
    Last Post: 02-21-2003, 09:58 PM
  5. Debug Assertion Failed
    By minesweeper in forum Windows Programming
    Replies: 5
    Last Post: 12-11-2002, 05:11 PM