Thread: local defintion errors?! Help

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    38

    local defintion errors?! Help

    Ok basicly I'm trying to add a menu to a program that sorts names entered. Giving the options of ascending and descending and exiting the program. But I keep getting local defintion errors.....thanks in advance.

    Code:
    #include "stdafx.h"
    
    #using <mscorlib.dll>
    
    using namespace System;
    using namespace std;
    
    void mfSkipLine(int);
    String* mfstrGetNames(int);
    
    int displayMenu();
    void asending();
    void desending();
    
    int _tmain()
    {
    	int intComp;
        int intCt;
    	int intCt1;
    	int intFound;
    	
    	
    
    	String* ComPar;
    	String* temp;
    
    	String* var1;
    	String* var2;
    	String* var3;
    	String* var4;
    	String* var5;
    
    	String* out1;
    	String* out2;	
    	String* out3;
    	String* out4;
    	String* out5;
    
    	int menuChoice = 0;
    	
    
    	Console::WriteLine("Alphabetical Order Program");
    	mfSkipLine(7);
    
    
    
    	menuChoice = displayMenu();
    
    while (menuChoice != 3)
    	{
    		if (menuChoice == 1)
    			asending();
    		else if (menuChoice == 2)
    			desending();
    		else
    			Console::WriteLine("Invalid menu choice");
    
    		menuChoice = displayMenu();
    	}
    	
    
    
    int displayMenu()
    {
    	Console::WriteLine("1		Ascending Order");
    	Console::WriteLine("2		Descending Order");
    	Console::WriteLine("3		Exit Program");
    	Console::Write("Enter Menu Option: ");
    	return Convert::ToInt32(Console::ReadLine());
    }
    {
    	intCt = 1;
    
    	while(intCt < 6)
    	{
    		temp = mfstrGetNames(intCt);
    
    		if(intCt == 1) var1 = temp;
    		if(intCt == 2) var2 = temp;
    		if(intCt == 3) var3 = temp;
    		if(intCt == 4) var4 = temp;
    		if(intCt == 5) var5 = temp;
    
    		intCt = intCt + 1;
    	}
    
    	mfSkipLine(2);
    
    	intCt = 1;
    
    	//loop 1
    	while (intCt < 6)
    	{
    		temp = "ZZZZZZZZZZ";
    		intFound = 0;
    		intCt1 = 1;
    		
    		while (intCt1 < 6)
    		{
    			if(intCt1 == 1) ComPar = var1;
    			if(intCt1 == 2) ComPar = var2;
    			if(intCt1 == 3) ComPar = var3;
    			if(intCt1 == 4) ComPar = var4;
    			if(intCt1 == 5) ComPar = var5;
    
    			intComp = temp->CompareTo(ComPar);
    
    			if (intComp == 1)
    			{
    				intFound = intCt1;
    				temp = ComPar;
    			}
    
    			intCt1 = intCt1 + 1;
    
    		}
    
    		if(intFound > 0)
    		{
    			if(intCt == 1) out1 = temp;
    			if(intCt == 2) out2 = temp;
    			if(intCt == 3) out3 = temp;
    			if(intCt == 4) out4 = temp;
    			if(intCt == 5) out5 = temp;
    
    			if(intFound == 1) var1 = "ZZZZZZZZZZZZZZZ";
    			if(intFound == 2) var2 = "ZZZZZZZZZZZZZZZ";
    			if(intFound == 3) var3 = "ZZZZZZZZZZZZZZZ";
    			if(intFound == 4) var4 = "ZZZZZZZZZZZZZZZ";
    			if(intFound == 5) var5 = "ZZZZZZZZZZZZZZZ";
    		}
    
    		intCt = intCt + 1;
    
    	}
    
    	intCt = 1;
    
    	while(intCt < 6)
    	{
    	
    		if(intCt==1) temp = out1;
    		if(intCt==2) temp = out2;
    		if(intCt==3) temp = out3;
    		if(intCt==4) temp = out4;
    		if(intCt==5) temp = out5;
    
    		Console::WriteLine(temp);
            
    		intCt = intCt + 1;
    	}
    
    	mfSkipLine(2);
    	Console::ReadLine();
    	return 0;
    
    }
    
    
    
    String* mfstrGetNames(int intCt)
    {
    	String* temp;
    	
    	Console::Write("Enter Name # {0}  : ", Convert::ToString(intCt));
    	temp = Console::ReadLine();	
    	return temp;
    	
    }
    
    void mfSkipLine (int intLines)
    {
    	int intCt;
    
    	intCt = intLines;
    
    	while (intCt > 0)
    	{
    		Console::WriteLine("");
    		 intCt = intCt - 1;
    	}
    }
    }

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    38
    No need to reply to my question guys, I figured it out lol...

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Glad you figured it out But for future reference, when you get errors it would be VERY helpful if you posted:
    a) Exactly what the error says
    b) The line that the error appears on.

    Good to see you used code tags though Happy coding!
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    On a side note, I strongly recommend that you use arrays instead of the numbered groups of variables. That allows you to use your integer as an index into the array.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 05-24-2009, 02:42 AM
  2. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  3. Need help with initialization errors
    By JoelearningC in forum C Programming
    Replies: 1
    Last Post: 03-08-2008, 03:16 PM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 01:43 PM