5 times "local function definitions are illegal"

This is a discussion on 5 times "local function definitions are illegal" within the C++ Programming forums, part of the General Programming Boards category; Hi everybody ! This is my first post and I hope I can deal with the forum well. I'm working ...

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    13

    5 times "local function definitions are illegal"

    Hi everybody !
    This is my first post and I hope I can deal with the forum well.

    I'm working on a program which currently has 7 errors in total. They aren't many but most of them are "local function definitions are illegal"

    The awkward is I've those errors mainly in function which are given by the lecturers.

    Code:
     
    struct ELEM
    { int key2,pole; ELEM *left, *right;}
    *root1, *root2 ;
    
    
    ELEM *search_iter(ELEM *t, int k) //
    { 
    while ((t!=NULL)&&(t->key2!=k))
    if (t->key2<k)
    t=t->right;
    else 
    t=t->left;
    return t;}
    
    
    error C2601: 'search_iter' : local function definitions are illegal
    
    
    
    calling :  
    if(search_iter(root1,NOMER)!=1) 
    
    ........



    My goal below is to go throw the elements and write in "pole" 0 .
    Code:
    void Available(ELEM *t, int n)
    {  
    	if ((t!=NULL)&&(t->key2==n)    
    	{     
    		t->pole=0;
    		preorder(t->left);
    		preorder(t->right);    
    	}
    
    
    }
    Error :
    'Available' : local function definitions are illegal

    Later I'll post some more errors.
    Any ideas ?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,993
    My guess is that in the code that you did not show, you defined a function and accidentally made this function encompass the other functions provided by your lecturers.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,687
    Look for a missing closing brace in the function you deleted, just before search_iter is defined.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,454
    It does help if you show actual code that illustrates the problem - rather than paraphrasing.

    The reason would be that you have placed the implementation of one function within the body of another. That is illegal in C++ (and C).

    For example;
    Code:
    #include <iostream>
    
    int main()
    {
         void do_something() {std::cout << "Hello\n";};
    
          do_something();
          return 0;
    }
    would trigger the same errors, but this .....
    Code:
    #include <iostream>
    
    void do_something() {std::cout << "Hello\n";}
    
    int main()
    {
          do_something();
          return 0;
    }
    would not.
    Right 98% of the time, and don't care about the other 3%.

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    Correct all of your indentation and you will spot the problem.

    Also, don't ever put the closing brace on the end of the previous line unless the opening brace is on the same line.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #6
    Registered User
    Join Date
    Jan 2011
    Posts
    13
    Quote Originally Posted by laserlight View Post
    My guess is that in the code that you did not show, you defined a function and accidentally made this function encompass the other functions provided by your lecturers.
    Yes, I did it.
    In my next post I'll show the whole program.


    Quote Originally Posted by Salem View Post
    Look for a missing closing brace in the function you deleted, just before search_iter is defined.
    Yes, thank you I check it

  7. #7
    Registered User
    Join Date
    Jan 2011
    Posts
    13
    OK, I think I've edited some braces, here is the whole program.
    The program is supposed to operate the flights in an airport.

    Only "Available" is own function and its goals are to write 0 in ELEM's "pole"

    Code:
    #include <iostream.h>
    #include <conio.h>
    struct elem  
    { int key1;  elem *next;}  
    	*start,*start1, *last,*last1;
    struct ELEM
    { int key2,pole; ELEM *left, *right;}
    	*root1, *root2 ;
    void push(int n)		//adding an element in queue(FIFO) 
    {
    	 elem *p=last;  
    	 last=new elem;  
    	 last->key1=n;
    	 last->next=NULL;  
    	 if(p!=NULL)
    		p->next=last;  
    	 if (start==NULL)	  	 
    		{start=last;}
    }
    void push1(int n)		// adding an element in queue(FIFO)
    {
    	 elem *p=last1;  
    	 last1=new elem;  
    	 last1->key1=n;
    	 last1->next=NULL; 
    	 if(p!=NULL) p->next=last1; 
    	 if (start1==NULL)	  	 
    	 {start1=last1;}
    }
    void addTREE(int n, ELEM	* &t)        // creating a binary tree 
    { 
    	if (t==NULL)    
    	{
    	       t=new ELEM;
    			t->key2=n;
    			t->left=t->right=NULL;
        }		else
       {				if (t->key2<n)	  
    					addTREE(n,t->right);
    	 			else
    	  
    					addTREE(n,t->left);    }
    }
    
    int search_recurs(struct elem *p, int n) 
    
    { 
    	if (start==NULL)	  
    	{				      
    		return 0;     }  
    	else     
    	{ if ((p->key1<n)&&(p->next==NULL))	
    		{			
    		   return 0;	}
    				else	    
    				  {if (p->key1==n) return 1;     
    				else	       
    				{ if (p->key1<n)		 
    				search_recurs(p->next, n);		   
    	else			    
    	{return 0;}   }
    }
    	} 
    }
    
    
    
    ELEM *search_iter(ELEM *t, int k) // Searching in binary tree
    { 
    	while ((t!=NULL)&&(t->key2!=k))
     if (t->key2<k)
    	        t=t->right;
        else
    		          
    		   t=t->left;
      return t;}
    void Available(ELEM *t, int n)
    {  
    	if ((t!=NULL)&&(t->key2==n))   
    	{     
    		t->pole=0;
    		Available(t->left,n);
    		Available(t->right,n);    
    	}
    }
    void preorder(ELEM *t)
    { 
    	if (t)   
    	{     cout<<t->key2<<" ";
    			preorder(t->left);     
    			preorder(t->right);    }
    }
    
    void Traverse(elem *p)
    {
    	while(p->next!=NULL) 
    	{
    		cout<<p->key1<<" ";
    		p=p->next;
    	}
    }
    
    void main () 
    
    { 
    
    	int ch,k,i,NOMER,NR; 
    	do 
    	{
    
    		int num ;
    
    		cout<<"     Menu\n";
    		cout<<"1- Add flying airplanes\n";
    		cout<<"2- Add landed airplanes \n";
    		cout<<"3- Add airplanes for landing\n";
    		cout<<"4- Add airplanes for taking off  \n";
    		cout<<"5- Show the tree of landed airplanes\n";
    		cout<<"6- Show the tree of flying airplanes \n";
    		cout<<"7- Show the queue -waiting taking off airplanes\n";
    		cout<<"8- Show the queue –waiting landing airplanes\n";
    		cout<<"9 –Show the condition of particular airplane \n";
    		cout<<"0- END.\n";
    		cout<<"Make your choice : \n";
    			cin>>ch;
    		switch(ch) {
    		case(1):  
    				cout<<"\n NOMER : ";
    				cin>>NOMER;
    				addTREE(NOMER,root1);
    		case(2):
    				cout<<"\n NOMER : ";
    				cin>>NOMER;
    				addTREE(NOMER,root2);	
    		case(3):
    				cout<<"\n NOMER : ";
    				cin>>k;
    				search_iter(root1,k);
    				push(k) ;
    				//pop(k);
    			   Available(root1,k);
    						
    		case(4):
    				cout<<"\n NOMER : ";
    				cin>>k;
    				search_iter(root2,k);
    				push1(k);
    				//pop1(k);
    				 
    				Available(root2,k);
    				
    		case(5): 	
    				preorder(root1);
    		case(6):
    				preorder(root2);
    		case(7):
    				Traverse(start);	
    		case(8):
    				Traverse(start1);
    		case(9):
    			{
    				cout<<"Add a number of particular airplane\n";
    				cin>>NR;
    				if(search_recurs(start,NR)!=0) 
    					cout<<"\n The airplane is in the queue for landing";
    				if(search_recurs(start1,NR)!=0) 
    					cout<<"\n The airplane is in the queue for taking off ";
    				if(search_iter(root1,NOMER)!=NULL) 
    					cout<<"\n The airplane is in the tree of flying";
    				if(search_iter(root2,NOMER)!=NULL) 	
    					cout<<"\n The airplane is in the tree of landed";
    				} 
    		}
    		while(ch!=0); 
    }
    Currently only one mistake - Unexpected end of file ...
    Very sad :s
    Last edited by Borislav; 01-04-2011 at 09:01 AM.

  8. #8
    Registered User
    Join Date
    Jan 2011
    Posts
    13
    Actually, I moderate

    "search_recurs"

    The original version is :
    Code:
    int search_recurs(struct elem *p, int n) 
    {
    				
     elem *q;			  
    if (start==NULL)		   {
    				   
    start=new elem;	  
    start->key=n;	      
     start->next=NULL; 
     return 0;    }      
     else     
    { if ((p->key<n)&&(p->next==NULL))		
    {				
      q=new elem;   
    q->key=n;	  
    q->next=NULL; 
    p->next=q; return 0;	}	 
    else	 	  
    { if (p->key==n) return 1; 		      
    else	        if (p->key<n)		 
     search_recurs(p->next, n);		  
      else				  
      {				     
    q=new elem; q->next=p->next;		   
      q->key=p->key; p->key=n;		    
     p->next=q; return 0;		    
    }	
       }     }}
    I don't need to add an extra element
    Last edited by Borislav; 01-04-2011 at 08:47 AM.

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,687
    You're making it hard for yourself with your haphazard approach to placing braces (and inconsistent use).

    Here is post 7 cleaned up with indent.
    Code:
    #include <iostream.h>
    #include <conio.h>
    
    struct elem {
        int key1;
        elem *next;
    } *start, *start1, *last, *last1;
    
    struct ELEM {
        int key2, pole;
        ELEM *left, *right;
    } *root1, *root2;
    
    void push(int n)                //adding an element in queue(FIFO)
    {
        elem *p = last;
        last = new elem;
        last->key1 = n;
        last->next = NULL;
        if (p != NULL)
            p->next = last;
        if (start == NULL) {
            start = last;
        }
    }
    
    void push1(int n)               // adding an element in queue(FIFO)
    {
        elem *p = last1;
        last1 = new elem;
        last1->key1 = n;
        last1->next = NULL;
        if (p != NULL)
            p->next = last1;
        if (start1 == NULL) {
            start1 = last1;
        }
    }
    
    void addTREE(int n, ELEM * &t)  // creating a binary tree
    {
        if (t == NULL) {
            t = new ELEM;
            t->key2 = n;
            t->left = t->right = NULL;
        } else {
            if (t->key2 < n)
                addTREE(n, t->right);
            else
                addTREE(n, t->left);
        }
    }
    
    int search_recurs(struct elem *p, int n)
    {
        if (start == NULL) {
            return 0;
        } else {
            if ((p->key1 < n) && (p->next == NULL)) {
                return 0;
            } else {
                if (p->key1 == n)
                    return 1;
                else {
                    if (p->key1 < n)
                        search_recurs(p->next, n);
                    else {
                        return 0;
                    }
                }
            }
        }
    }
    
    ELEM *search_iter(ELEM * t, int k)  // Searching in binary tree
    {
        while ((t != NULL) && (t->key2 != k))
            if (t->key2 < k)
                t = t->right;
            else
                t = t->left;
        return t;
    }
    
    void Available(ELEM * t, int n)
    {
        if ((t != NULL) && (t->key2 == n)) {
            t->pole = 0;
            Available(t->left, n);
            Available(t->right, n);
        }
    }
    
    void preorder(ELEM * t)
    {
        if (t) {
            cout << t->key2 << " ";
            preorder(t->left);
            preorder(t->right);
        }
    }
    
    void Traverse(elem * p)
    {
        while (p->next != NULL) {
            cout << p->key1 << " ";
            p = p->next;
        }
    }
    
    void main()
    {
    
        int ch, k, i, NOMER, NR;
        do {
    
            int num;
    
            cout << "     Menu\n";
            cout << "1- Add flying airplanes\n";
            cout << "2- Add landed airplanes \n";
            cout << "3- Add airplanes for landing\n";
            cout << "4- Add airplanes for taking off  \n";
            cout << "5- Show the tree of landed airplanes\n";
            cout << "6- Show the tree of flying airplanes \n";
            cout << "7- Show the queue -waiting taking off airplanes\n";
            cout << "8- Show the queue –waiting landing airplanes\n";
            cout << "9 –Show the condition of particular airplane \n";
            cout << "0- END.\n";
            cout << "Make your choice : \n";
            cin >> ch;
            switch (ch) {
            case (1):
                cout << "\n NOMER : ";
                cin >> NOMER;
                addTREE(NOMER, root1);
            case (2):
                cout << "\n NOMER : ";
                cin >> NOMER;
                addTREE(NOMER, root2);
            case (3):
                cout << "\n NOMER : ";
                cin >> k;
                search_iter(root1, k);
                push(k);
                //pop(k);
                Available(root1, k);
    
            case (4):
                cout << "\n NOMER : ";
                cin >> k;
                search_iter(root2, k);
                push1(k);
                //pop1(k);
    
                Available(root2, k);
    
            case (5):
                preorder(root1);
            case (6):
                preorder(root2);
            case (7):
                Traverse(start);
            case (8):
                Traverse(start1);
            case (9):
                {
                    cout << "Add a number of particular airplane\n";
                    cin >> NR;
                    if (search_recurs(start, NR) != 0)
                        cout << "\n The airplane is in the queue for landing";
                    if (search_recurs(start1, NR) != 0)
                        cout <<
                            "\n The airplane is in the queue for taking off ";
                    if (search_iter(root1, NOMER) != 1)
                        cout << "\n The airplane is in the tree of flying";
                    if (search_iter(root2, NOMER) != 1)
                        cout << "\n The airplane is in the tree of landed";
                }
            }
            while (ch != 0);
        }
    }
    All your cases in main need a break; statement.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  10. #10
    Registered User
    Join Date
    Jan 2011
    Posts
    13
    Quote Originally Posted by Salem View Post
    You're making it hard for yourself with your haphazard approach to placing braces (and inconsistent use).

    Here is post 7 cleaned up with indent.
    Code:
    #include <iostream.h>
    #include <conio.h>
    
    struct elem {
        int key1;
        elem *next;
    } *start, *start1, *last, *last1;
    
    struct ELEM {
        int key2, pole;
        ELEM *left, *right;
    } *root1, *root2;
    
    void push(int n)                //adding an element in queue(FIFO)
    {
        elem *p = last;
        last = new elem;
        last->key1 = n;
        last->next = NULL;
        if (p != NULL)
            p->next = last;
        if (start == NULL) {
            start = last;
        }
    }
    
    void push1(int n)               // adding an element in queue(FIFO)
    {
        elem *p = last1;
        last1 = new elem;
        last1->key1 = n;
        last1->next = NULL;
        if (p != NULL)
            p->next = last1;
        if (start1 == NULL) {
            start1 = last1;
        }
    }
    
    void addTREE(int n, ELEM * &t)  // creating a binary tree
    {
        if (t == NULL) {
            t = new ELEM;
            t->key2 = n;
            t->left = t->right = NULL;
        } else {
            if (t->key2 < n)
                addTREE(n, t->right);
            else
                addTREE(n, t->left);
        }
    }
    
    int search_recurs(struct elem *p, int n)
    {
        if (start == NULL) {
            return 0;
        } else {
            if ((p->key1 < n) && (p->next == NULL)) {
                return 0;
            } else {
                if (p->key1 == n)
                    return 1;
                else {
                    if (p->key1 < n)
                        search_recurs(p->next, n);
                    else {
                        return 0;
                    }
                }
            }
        }
    }
    
    ELEM *search_iter(ELEM * t, int k)  // Searching in binary tree
    {
        while ((t != NULL) && (t->key2 != k))
            if (t->key2 < k)
                t = t->right;
            else
                t = t->left;
        return t;
    }
    
    void Available(ELEM * t, int n)
    {
        if ((t != NULL) && (t->key2 == n)) {
            t->pole = 0;
            Available(t->left, n);
            Available(t->right, n);
        }
    }
    
    void preorder(ELEM * t)
    {
        if (t) {
            cout << t->key2 << " ";
            preorder(t->left);
            preorder(t->right);
        }
    }
    
    void Traverse(elem * p)
    {
        while (p->next != NULL) {
            cout << p->key1 << " ";
            p = p->next;
        }
    }
    
    void main()
    {
    
        int ch, k, i, NOMER, NR;
        do {
    
            int num;
    
            cout << "     Menu\n";
            cout << "1- Add flying airplanes\n";
            cout << "2- Add landed airplanes \n";
            cout << "3- Add airplanes for landing\n";
            cout << "4- Add airplanes for taking off  \n";
            cout << "5- Show the tree of landed airplanes\n";
            cout << "6- Show the tree of flying airplanes \n";
            cout << "7- Show the queue -waiting taking off airplanes\n";
            cout << "8- Show the queue –waiting landing airplanes\n";
            cout << "9 –Show the condition of particular airplane \n";
            cout << "0- END.\n";
            cout << "Make your choice : \n";
            cin >> ch;
            switch (ch) {
            case (1):
                cout << "\n NOMER : ";
                cin >> NOMER;
                while(NOMER!=0)
                addTREE(NOMER, root1);
            case (2):
                cout << "\n NOMER : ";
                cin >> NOMER;
                while(NOMER!=0)
                addTREE(NOMER, root2);
            case (3):
                cout << "\n NOMER : ";
                cin >> k;
                while(k!=0)
                search_iter(root1, k);
                push(k);
                 Available(root1, k);
    
            case (4):
                cout << "\n NOMER : ";
                cin >> k;
                while(k!=0)
                search_iter(root2, k);
                push1(k);
                 Available(root2, k);
    
            case (5):
                preorder(root1);
    break;
            case (6):
                preorder(root2);
                break;
    
            case (7):
                Traverse(start);
                 break;
    
            case (8):
                Traverse(start1);
                break;
    
            case (9):
                {
                    cout << "Add a number of particular airplane\n";
                    cin >> NR;
                    while (NR!=0) 
                { 
    
                     if (search_recurs(start, NR) != 0)
                        cout << "\n The airplane is in the queue for landing";
                    if (search_recurs(start1, NR) != 0)
                        cout <<
                            "\n The airplane is in the queue for taking off ";
                    if (search_iter(root1, NOMER) != 1)
                        cout << "\n The airplane is in the tree of flying";
                    if (search_iter(root2, NOMER) != 1)
                        cout << "\n The airplane is in the tree of landed";
                 }            
                   }
            }
            while (ch != 0);
        }
    }
    All your cases in main need a break; statement.
    How about this ?
    I still have unexpected end of file ..

  11. #11
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,687
    Yeah I noticed - I put one at the end of the file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  12. #12
    Registered User
    Join Date
    Jan 2011
    Posts
    13
    hmm I'm having a problem with making an .EXE file.
    Can this make such a big problem ?

    With one brace in the end here what it displays :
    Code:
    --------------------Configuration: XAXA - Win32 Debug--------------------
    Compiling...
    XAXA.CPP
    D:\XAXA.CPP(201) : fatal error C1004: unexpected end of file found
    Error executing cl.exe.
    
    XAXA.exe - 1 error(s), 0 warning(s)
    Last edited by Borislav; 01-04-2011 at 11:46 AM.

  13. #13
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,823
    But an extra new line at the end of the file. See if that helps.
    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.

  14. #14
    Registered User
    Join Date
    Jan 2011
    Posts
    13
    Quote Originally Posted by Elysia View Post
    But an extra new line at the end of the file. See if that helps.
    Even with 3 lines it doesn't help.


    I'm using Microsoft Visual C++ 6.0, with virtual CD - any problems here ?
    In the newest version Microsoft Visual C++ 2010 Express I can't understand how to start the program and compilator.From Microsoft should make it simplier.

    In Turbo C version I haven't tried my program due to the COPY-PASTE problem and I don't want to write it again.

  15. #15
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,687
    Watch the //!! comments
    Code:
    #include <iostream>
    using namespace std;
    
    struct elem {
        int key1;
        elem *next;
    } *start, *start1, *last, *last1;
    
    struct ELEM {
        int key2, pole;
        ELEM *left, *right;
    } *root1, *root2;
    
    void push(int n)                //adding an element in queue(FIFO)
    {
        elem *p = last;
        last = new elem;
        last->key1 = n;
        last->next = NULL;
        if (p != NULL)
            p->next = last;
        if (start == NULL) {
            start = last;
        }
    }
    
    void push1(int n)               // adding an element in queue(FIFO)
    {
        elem *p = last1;
        last1 = new elem;
        last1->key1 = n;
        last1->next = NULL;
        if (p != NULL)
            p->next = last1;
        if (start1 == NULL) {
            start1 = last1;
        }
    }
    
    void addTREE(int n, ELEM * &t)  // creating a binary tree
    {
        if (t == NULL) {
            t = new ELEM;
            t->key2 = n;
            t->left = t->right = NULL;
        } else {
            if (t->key2 < n)
                addTREE(n, t->right);
            else
                addTREE(n, t->left);
        }
    }
    
    int search_recurs(struct elem *p, int n)
    {
        if (start == NULL) {
            return 0;
        } else {
            if ((p->key1 < n) && (p->next == NULL)) {
                return 0;
            } else {
                if (p->key1 == n)
                    return 1;
                else {
                    if (p->key1 < n)
                        search_recurs(p->next, n);
                    else {
                        return 0;
                    }
                }
            }
        }
    }
    
    ELEM *search_iter(ELEM * t, int k)  // Searching in binary tree
    {
        while ((t != NULL) && (t->key2 != k))
            if (t->key2 < k)
                t = t->right;
            else
                t = t->left;
        return t;
    }
    
    void Available(ELEM * t, int n)
    {
        if ((t != NULL) && (t->key2 == n)) {
            t->pole = 0;
            Available(t->left, n);
            Available(t->right, n);
        }
    }
    
    void preorder(ELEM * t)
    {
        if (t) {
            cout << t->key2 << " ";
            preorder(t->left);
            preorder(t->right);
        }
    }
    
    void Traverse(elem * p)
    {
        while (p->next != NULL) {
            cout << p->key1 << " ";
            p = p->next;
        }
    }
    
    int main()  //!! Yes, REALLY - main returns int
    {
    
        int ch, k, i, NOMER, NR;
        do {
    
            int num;
    
            cout << "     Menu\n";
            cout << "1- Add flying airplanes\n";
            cout << "2- Add landed airplanes \n";
            cout << "3- Add airplanes for landing\n";
            cout << "4- Add airplanes for taking off  \n";
            cout << "5- Show the tree of landed airplanes\n";
            cout << "6- Show the tree of flying airplanes \n";
            cout << "7- Show the queue -waiting taking off airplanes\n";
            cout << "8- Show the queue –waiting landing airplanes\n";
            cout << "9 –Show the condition of particular airplane \n";
            cout << "0- END.\n";
            cout << "Make your choice : \n";
            cin >> ch;
            switch (ch) {
            case (1):
                cout << "\n NOMER : ";
                cin >> NOMER;
                addTREE(NOMER, root1);
            case (2):
                cout << "\n NOMER : ";
                cin >> NOMER;
                addTREE(NOMER, root2);
            case (3):
                cout << "\n NOMER : ";
                cin >> k;
                search_iter(root1, k);
                push(k);
                //pop(k);
                Available(root1, k);
    
            case (4):
                cout << "\n NOMER : ";
                cin >> k;
                search_iter(root2, k);
                push1(k);
                //pop1(k);
    
                Available(root2, k);
    
            case (5):
                preorder(root1);
            case (6):
                preorder(root2);
            case (7):
                Traverse(start);
            case (8):
                Traverse(start1);
            case (9):
                {
                    cout << "Add a number of particular airplane\n";
                    cin >> NR;
                    if (search_recurs(start, NR) != 0)
                        cout << "\n The airplane is in the queue for landing";
                    if (search_recurs(start1, NR) != 0)
                        cout <<
                            "\n The airplane is in the queue for taking off ";
                    if (search_iter(root1, NOMER) != NULL)  //!! WAS 1
                        cout << "\n The airplane is in the tree of flying";
                    if (search_iter(root2, NOMER) != NULL)  //!! WAS 1
                        cout << "\n The airplane is in the tree of landed";
                }
            }
        }
        while (ch != 0);    //!! MOVED down one }
    
        return 0;           //!! Tell the environment we were successful
    }
    Also note the use of iostream and using namespace std;
    Only use a modern compiler which understands these things. Do not try this with some fossil turboc relic from the past.

    Oh, one more thing, I only made it COMPILE.
    The run-time bugs are still for you to fix.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  3. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  4. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  5. help writing function definitions
    By jlmac2001 in forum C++ Programming
    Replies: 2
    Last Post: 04-10-2003, 09:44 PM

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