Stupid Me...... Crashes

This is a discussion on Stupid Me...... Crashes within the C++ Programming forums, part of the General Programming Boards category; Is it possible, from looking at this ....thing.... from my program, to tell if this goodamn function has a bug? ...

  1. #1
    Gronkulator of Surds littleweseth's Avatar
    Join Date
    Oct 2003
    Posts
    68

    Stupid Me...... Crashes

    Is it possible, from looking at this ....thing.... from my program, to tell if this goodamn function has a bug? it compiles, but when i try and run it in main..... results are spectacular. Program crashes (not winblows tho), once i got beeps, blah.

    Code:
    class GuiElement {
    public :
    	bool OutOfBounds	();						//Returns true if box will not fit on screen.	
    	
    	//Appearance Accessors
    	int ChangeColor		( int ArgBox, int ArgHead, int ArgText );
    	int ChangeThickness ( bool ArgThickness );
    	int ChangeSizePos	( int ArgXPos, int ArgYPos, int ArgXSize, int ArgYSize );
    	int ChangePosition	( int ArgPos, int ArgYPos );
    	int ChangeSize		( int ArgXSize, int ArgYSize );
    protected :
    	//Appearance Characteristics
    	unsigned short int 	BoxColor;				//Colour the box will be
    	unsigned short int 	HeaderColor;			//Colour the header will be
    	unsigned short int 	TextColor;				//Colour text will be
    	bool				Thickness;				//Thickness of box ( single or double )
    	//size/position
    	int	XPos;
    	int	YPos;
    	int	XSize;
    	int	YSize;
    };
    
    class TextBox : public GuiElement{
    public :
    	//Output
    	virtual int Display			();								//displays as a textbox with.... box.
    	int Range			( int ArgStart, int ArgEnd );	//Displays a given portion of the text string without the box.
    	//Editing Functions
    	int Prepend			( string szArgText );			//Add to the start
    	int Append			( string szArgText );			//Add to the end
    	int Rewrite			( string szArgText );			//Totally rewrites contents of string.
    	int ChangeHeader	( string szArgHeader );			//Totally rewrites header string.
    	
    	//Error Checking Functions : as well as returning true, they will also output a log to a file
    //	bool TextSizeIllegal();								//Returns true if size of text exceeds what can fit in box.
    //	bool HeaderIllegal	();								//Returns true if header wil not fit.
    protected :
    	//Text
    	string szHeader;									//Holds the header
    	string szText;										//Holds the actual text
    };
    
    int TextBox::Display()
    {
    	Draw Draw;
    	Draw.ChangeColor		( BoxColor );
    	Draw.Box				( XPos, YPos, XSize, YSize, Thickness );
    	Draw.CursorLocation		( XPos + 1, YPos + 1 );		//relocate the curosr to the top left corner of teh box
    	Draw.ChangeColorGlobal	( HeaderColor );
    	cout.write				( szHeader.c_str(), XSize - 2 );	//Make sure you dont write over the box
    	Draw.CursorLocation		( XPos + 1, YPos + 2 );
    	int i;
    	int j;
    	int k;
    	for ( i = 0 ; i < YSize - 2 ; i++ )
    		{
       		Draw.CursorLocation ( XPos + 1, YPos + 2 + i);
    		 for ( j = 0 ; j < XSize - 2 ; j++ )
    		 	{
    		 	
    		 	if ( szText [k] == 32 || j == XSize - 3 )
    		 		cout << "-";
    			else
    		 		cout << szText [k];
    			k++;
    		 	}
    		}
       	return 0;
    }
    if you took the time to read all of this uncommented..... kudos to you (what is a kudo??)

    Thanks for the couple of hours youll spend scratching your head in confusion and derision :)

    (edit) sorry about the tabs - they look fine in my IDE.... i have weird settings on tabs.
    Ph33r the sphericalCUBE

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,701
    Your indexing szText with an uninitialized variable.
    This would be easy to find using a debugger.

    gg

  3. #3
    Gronkulator of Surds littleweseth's Avatar
    Join Date
    Oct 2003
    Posts
    68
    SCHIEZER!! i havent figgerd out the debugger on devc++ yet - all i can do is set break points and look at thebacktrace.....
    thanks
    Ph33r the sphericalCUBE

  4. #4
    Gronkulator of Surds littleweseth's Avatar
    Join Date
    Oct 2003
    Posts
    68
    ok, so that didnt fix it. i scattered pauses all through.....

    SCHIEZER - more uninitialised variables! all through the damn thing!!!

    thanks for helping find the base source of my woes though.
    Ph33r the sphericalCUBE

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program crashes and memory leaks
    By ulillillia in forum Tech Board
    Replies: 1
    Last Post: 05-15-2007, 11:54 PM
  2. DEV-C++ made program crashes when run from outside the ide
    By rainmanddw in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2006, 10:27 PM
  3. stupid, stupid question
    By xelitex in forum C++ Programming
    Replies: 5
    Last Post: 12-22-2004, 08:22 PM
  4. Incredibly Stupid People
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 09-09-2003, 05:12 PM
  5. Program crashes and I can't figure out why
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 09-19-2001, 06:33 PM

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