home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap07 / xmas.c < prev   
Encoding:
C/C++ Source or Header  |  1988-04-05  |  682 b   |  38 lines

  1. /* xmas.c -- fills an array with values, then passes */
  2. /*           each of those values to a function.     */
  3.  
  4. main()
  5. {
  6.     int i, j, widths[20];
  7.     void Center_out();
  8.  
  9.     for (i = 0, j = 1; i < 18; ++i, j += 2)
  10.         {
  11.         widths[i] = j;
  12.         }
  13.     widths[i++] = 3;
  14.     widths[i] = 3;
  15.  
  16.     for (i = 0; i < 20; i++)
  17.         {
  18.         Center_out('X', widths[i]);
  19.         }
  20.  
  21. }
  22.  
  23. void Center_out(char character, int width)
  24. {
  25.     int i;
  26.  
  27.     for (i = 0; i < ((80 - width) / 2); ++i)
  28.         {
  29.         putch(' ');
  30.         }
  31.     for (i = 0; i < width; ++i)
  32.         {
  33.         putch(character);
  34.         }
  35.     putch('\r');
  36.     putch('\n');
  37. }
  38.