Thread: continue statement causing an unexpected error

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    27

    continue statement causing an unexpected error

    Hi all,
    First of all I should say that I am attempting the following using MFC.
    I am trying to find the lowest scoring object in an array of objects called LineArray. Whenever a low score is found it is tested against all the other scores. If its position in the array is noted so that it can be copied back in later.
    the code for the function is below
    Code:
    void FindTenBest(CLine LineArray[])
    {
    	
    	int number1 =5000; //lowest cost of line
    	int number2 =5000; //next lowest cost of line
    	int number3 =5000; //next lowest cost of line
    	int number4 =5000; //next lowest cost of line
    	int number5 =5000; //next lowest cost of line
    	int number6 =5000; //next lowest cost of line
    	int number7 =5000; //next lowest cost of line
    	int number8 =5000; //next lowest cost of line
    	int number9 =5000; //next lowest cost of line
    	int number10 =5000; //next lowest cost of line
    
    	for(int i=10;i<1010;i++)
    	{
    		if(LineArray[i].m_Cost<number1)
    		{
    			number10 = i;
    			continue;
    		}
    
    		if(LineArray[i].m_Cost<number2)
    		{
    			number9 = i;
    			continue;
    		}
    		
    		if(LineArray[i].m_Cost<number3)
    		{
    			number8 = i;
    			continue;
    		}
    
    		if(LineArray[i].m_Cost<number4)
    		{
    			number7 = i;
    			continue;
    		}
    		
    		if(LineArray[i].m_Cost<number5)
    		{
    			number6 = i;
    			continue;
    		}
    
    		if(LineArray[i].m_Cost<number6)
    		{
    			number5 = i;
    			continue;
    		}
    
    		if(LineArray[i].m_Cost<number7)
    		{
    			number4 = i;
    			continue;
    		}
    
    		if(LineArray[i].m_Cost<number8)
    		{
    			number3 = i;
    			continue;
    		}
    
    		if(LineArray[i].m_Cost<number9)
    		{
    			number2 = i;
    			continue;
    		}
    
    		if(LineArray[i].m_Cost<number10)
    		{
    			number1 = i;
    			continue;
    		}
    	}
    	LineArray[0] = LineArray[number1]; //store them in the array
    	LineArray[1] = LineArray[number2]; //store them in the array
    	LineArray[2] = LineArray[number3]; //store them in the array
    	LineArray[3] = LineArray[number4]; //store them in the array
    	LineArray[4] = LineArray[number5]; //store them in the array
    	LineArray[5] = LineArray[number6]; //store them in the array
    	LineArray[6] = LineArray[number7]; //store them in the array
    	LineArray[7] = LineArray[number8]; //store them in the array
    	LineArray[8] = LineArray[number9]; //store them in the array
    	LineArray[9] = LineArray[number10]; //store them in the array
    }
    The first ten places in the array are held for the lowest scoring ones. Otherwise 1000 other objects are created (10-1010). And these are the ones to be checked. The problem is that without the continue statement the lowest scoring object occupies the entire first ten. However when i use the continue statement and run the program it causes the error screen to appear. The error it would seem is:
    Code:
    oaded 'C:\WINDOWS\SYSTEM32\ntdll.dll', no matching symbolic information found.
    Loaded 'C:\WINDOWS\SYSTEM32\kernel32.dll', no matching symbolic information found.
    Loaded symbols for 'C:\WINDOWS\SYSTEM32\MFC42D.DLL'
    Loaded symbols for 'C:\WINDOWS\SYSTEM32\MSVCRTD.DLL'
    Loaded 'C:\WINDOWS\SYSTEM32\gdi32.dll', no matching symbolic information found.
    Loaded 'C:\WINDOWS\SYSTEM32\user32.dll', no matching symbolic information found.
    Loaded 'C:\WINDOWS\SYSTEM32\advapi32.dll', no matching symbolic information found.
    Loaded 'C:\WINDOWS\SYSTEM32\rpcrt4.dll', no matching symbolic information found.
    Loaded symbols for 'C:\WINDOWS\SYSTEM32\MFCO42D.DLL'
    Loaded 'C:\WINDOWS\SYSTEM32\uxtheme.dll', no matching symbolic information found.
    Loaded 'C:\WINDOWS\SYSTEM32\msvcrt.dll', no matching symbolic information found.
    Loaded 'C:\WINDOWS\SYSTEM32\comctl32.dll', no matching symbolic information found.
    Loaded 'C:\WINDOWS\SYSTEM32\version.dll', no matching symbolic information found.
    Loaded 'C:\WINDOWS\SYSTEM32\shlwapi.dll', no matching symbolic information found.
    Loaded 'C:\WINDOWS\SYSTEM32\apphelp.dll', no matching symbolic information found.
    The thread 0x33C has exited with code 0 (0x0).
    The thread 0x794 has exited with code -1073741819 (0xC0000005).
    This has no meaning to me whatsoever. I have tried running the program only up until i<1000; so it can't be that its running out of bounds with the array. I'm really stuck as to what it means. As ever any help would be greatly appreciated.
    Many thanks
    Dylan

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    27

    Sorry everyone

    opkay sorry I should have checked my code through.
    The problem for anyone that is interested seems to be related to the fact that that I hadn't changed the number being compared to the number that was being recorded.
    My apologies.
    Dylan

  3. #3
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    I'm not exactly sure, but you are doing the same thing over and over again, sice each numberx = 5000;

    axon

    EDIT------
    I SEE you beat me too it! LOL

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  2. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  3. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM