home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / R_LA4_01.ZIP / MOVE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-12-25  |  2.1 KB  |  53 lines

  1. /****************************************************************/
  2. /* MOVE.C - A rocket program typed from the book "Microsoft C   */
  3. /* Programming for the IBM" by Robert Lafore. The program is on */
  4. /* page 241. This program doesn't work like it should. See      */
  5. /* the file ROCKET.C on this disk for one that works a little   */
  6. /* better.                                                      */
  7. /****************************************************************/
  8.  
  9. #define ROWS 10
  10. #define COLS 5
  11.  
  12. main()
  13. {
  14. int count, j, k;
  15. char *ptr[ROWS];           /*pointers to rows*/
  16. char *temp;                /*pointer storage*/
  17. static char pict[ROWS][COLS] = {       /* rocketship */
  18.       { 0,        0,       0,       0,       0          },
  19.       { 0,        0,       0,       0,       0          },
  20.       { 0,        0,       0,       0,       0          },
  21.       { 0,        0,       0,       0,       0          },
  22.       { 0,        0,       0,       0,       0          },
  23.       { 0,        0,       0,       0,       0          },
  24.       { 0,        0,       0,       0,       0          },
  25.       { 0,        0,       0,       0,       0          },
  26.       { 0,        0,       '\x1E',  0,       0          },
  27.       { 0,        '\x1E',  '\x1E',  '\x1E',  0          }  };
  28.  
  29. static char gnd[] =        /* ground line */
  30.             { '\xCD', '\xCD', '\xCD', '\xCD', '\xCD' };
  31.  
  32.    for(count = 0; count < ROWS; count++)     /*set up pointers*/
  33.       *(ptr + count) = *(pict + count);
  34.  
  35.    for(count = 0; count < ROWS - 1; count++) {
  36.       for(j = 0; j < ROWS; j++) {            /*print rocket*/
  37.          for(k = 0; k < COLS; k++)
  38.             if (*(*(ptr + j) + k) != 0) {
  39.                for(k = 0; k < COLS; k++)
  40.                   printf("%c", *(*(ptr + j) + k));
  41.                printf("%c", '\n');
  42.                break;
  43.             }
  44.       }
  45.       printf("%s\n", gnd);                   /*print ground*/
  46.       temp = *ptr;               /*rotate pointers*/
  47.       for(j = 0; j < ROWS - 1; j++)
  48.          *(ptr + j) = *(ptr + j + 1);
  49.       *(ptr + ROWS - 1) = temp;
  50.    }
  51. }
  52.  
  53.