title: How to declare function in other function?
body: <p>So I'm making quiz in opengl with c++. The problem is that I don't know how to declare function inside other function, so I have an error.</p>
  
  <pre><code>void main_menu_display()
  {
      glClear(GL_COLOR_BUFFER_BIT);
  
      // code to draw main menu
  
      glutSwapBuffers();
  }
  
  void main_menu_key(unsigned char key, int x, int y)
  {
  </code></pre>
  
  <p>I also tried this, to solve errors: //void first_screen_display();
          //void first_screen_key();</p>
  
  <pre><code>    switch(key)
      {
      case 27: //&lt; escape -&gt; quit
         exit(0);
      case 13: //&lt; enter -&gt; goto first display
         glutDisplayFunc(first_screen_display);
         glutKeyboardFunc(first_screen_key);
         break;
  </code></pre>
  
  <p>and there's error: 'first_screen_display' was not declared in this scope 
  and same happens with first screen key.</p>
  
  <pre><code>    }
      glutPostRedisplay();
  }
  
  void first_screen_display()
  {
      glClear(GL_COLOR_BUFFER_BIT);
  
      // code to draw first screen of game
  
      glutSwapBuffers();
  }
  
  void first_screen_key(unsigned char key, int x, int y)
  {
      switch(key)
      {
      case 27: //&lt; escape -&gt; return to main menu
         glutDisplayFunc(first_screen_display);
         glutKeyboardFunc(first_screen_key);
         break;
      /* other stuff */
      default:
         break;
      }
      glutPostRedisplay();
  }
  
  int main(int argc, char* argv[]) //argument count, argument variables
  {
      glutInit(&amp;argc, argv);
      glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
      glutInitWindowSize(600,600);
      glutInitWindowPosition(100,100);
      glutCreateWindow("Quiz");
      glutDisplayFunc(main_menu_display); 
      glutKeyboardFunc(main_menu_key); 
  
      //glutDisplayFunc(first_screen_display); 
      //glutKeyboardFunc(first_screen_key);
      Init();
  
  
  
      glutMainLoop();
      return 0;
  }
  </code></pre>