# Vertical Layout using a Loop

    #include <stdio.h>
    #include "graphapp.h"

    void quit(Control *c)
    {
      exit(0);
    }

    int main(int argc, char *argv[])
    {
      App *app;
      Window *w;
      Control *c;
      Control *b[5];
      Rect r;
      char * name[5] = {
            "Quit",
            "Button 1", "Button 2",
            "Button 3", "Button 4" };
      int i;

      app = new_app(argc, argv);
      w = new_window(app, rect(50,50,120,145),
                     "Vertical Layout", STANDARD_WINDOW);
      r = rect(0,0,80,25);

      for (i=0; i < 5; i++) {
        b[i] = new_button(w, r, name[i], quit);
        r.y = r.y + 30;
      }

      show_window(w);
      main_loop(app);
      return 0;
    }

Notes:

- An array of button names is now used.
- A "for loop" makes vertical or horizontal layout easy.