Thread: strange function problem...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    255

    strange function problem...

    Code:
    #include <iostream>
    #include <string>
    #include <cstring>
    #include <fstream>
    #include <cstdio>
    
    using namespace std;
    int open_menu1();
    
    
    
    
    struct stats
    {
    	int hp;
    	int mp;
    	int pl;
    	string items;
    	int wins;
    	int losses;
    	double time;
    };
    
    
    
    
    int main()
    {
    
    	ofstream out;
    	ifstream in;
    	string save;
    	bool test;
    	int menu = 0;
    	while (menu != 4)
    	{
    		menu = open_menu1();
    		if (menu == 1)
    		{
    			test = true;
    			system("cls");
    			cout << "please enter where you want to save this DOS style?\n";
    			getline(cin,save);
    			out.open(save.c_str(), ios::out);
    		}
    		else if(menu == 2)
    		{
    			test = false;
    			system("cls");
    			cout << "\nplease enter DOS style where you want to load the file from?\n";
    			getline(cin,save);
    			in.open(save.c_str(),ios::in);
    		}
    		else if(menu == 3)
    		{
    			system("cls");
    			cout << "STOP ENTERING STUFF I HAVENT DONE YET\n";
    		}
    		else;
    		if (test == true)
    			out.close();
    		else
    			in.close();
    
    return 0;
    	}		
    
    
    
    int open_menu1()
    {
    	int choice;
    	cout << "1.new\n2.load\n3.options\n4.quit\n";
    	cin >> choice;
    	return choice;
    }

    :\Documents and Settings\Owner\Desktop\C++ 6 files\New Folder\text game.cpp(71) : error C2601: 'open_menu1' : local function definitions are illegal
    C:\Documents and Settings\Owner\Desktop\C++ 6 files\New Folder\text game.cpp(78) : fatal error C1004: unexpected end of file found
    Error executing cl.exe.


    the error is pointing to the first bracket on the open_menu1 function and i have no clue why none at all
    hooch

  2. #2
    Hi ay_okay's Avatar
    Join Date
    Dec 2004
    Location
    Here
    Posts
    69
    Your return 0; should be after the bracket and then add one after return 0; like this:
    Code:
     else;
    		if (test == true)
    			out.close();
    		else
    			in.close();
    
    
    	}    //here is your problem(this is fixed version)
    return 0;		
    }
    
    
    int open_menu1()
    {
    etc...
    We all forget the bracket

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    255
    stupid bracket lol

    one thing .NET does that i like it highlights it so you can see as you go if nothing i love that .NET feature lol just hate C++.net(stupid school)
    hooch

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Replies: 6
    Last Post: 03-02-2005, 02:45 AM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM