home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap04 / graphbox.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-05  |  1.2 KB  |  55 lines

  1.  
  2. /* GRAPHBOX.C -- defined to use PC-specific */
  3. /*               graphics characters        */
  4.  
  5. #define NL 10
  6. #define CR 13
  7. #define BLANK 32
  8. #define UPLEFT 201
  9. #define UPRIGHT 187
  10. #define LOWLEFT 200
  11. #define LOWRIGHT 188
  12. #define LINE 205
  13. #define SIDE 186
  14.  
  15. main()
  16. {
  17.     int i, j, height, width;
  18.  
  19.     /* get height and width from user */
  20.     printf("How high a box do you want? ");
  21.     scanf("%d", &height);
  22.     printf("How wide do you want it to be? ");
  23.     scanf("%d", &width);
  24.  
  25.     /* draw top of box */
  26.     putch(UPLEFT);
  27.     for (i = 0; i < (width - 2); i++)
  28.         putch(LINE);
  29.     putch(UPRIGHT);
  30.     putch(NL);
  31.     putch(CR); /* go to next line */
  32.  
  33.     /* draw sides of box */
  34.     for (i = 0; i < height - 2; i++)  /* outer loop */
  35.         {
  36.         putch(SIDE); /* left side */
  37.         for (j = 0; j < (width - 2); j++) /* inner loop */
  38.             {
  39.             putch(BLANK);
  40.             }
  41.         putch(SIDE); /* right side */
  42.         putch(NL);
  43.         putch(CR); /* move to next line */
  44.         }
  45.  
  46.     /* draw bottom of box */
  47.     putch(LOWLEFT);
  48.     for (i = 0; i < (width - 2); i++)
  49.         putch(LINE);
  50.     putch(LOWRIGHT);
  51.     putch(NL);
  52.     putch(CR); /* box is done, move cursor to new line */
  53. }
  54.  
  55.