home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.pdx.edu / 2014.02.ftp.ee.pdx.edu.tar / ftp.ee.pdx.edu / pub / users / Harry / compilers / p7 / main.c < prev    next >
C/C++ Source or Header  |  2006-01-09  |  1KB  |  55 lines

  1. /* main.c
  2. **
  3. ** CS-322 - project 7 - Driver main routine
  4. */
  5.  
  6. #include <stdio.h>
  7.  
  8. int * iscan (int *, int);
  9. double * dscan (double *, int);
  10.  
  11. int    a[] = {3, 4, 5, 6, 7, -8};
  12. double b[] = {3.0, 4.0, 5.0, 6.0, 7.0, -8.0};
  13.  
  14. main()
  15. {
  16.     int i;
  17.     int *c;
  18.     double *d;
  19.  
  20.     c = iscan (a, 6);
  21.     if (c == NULL) {
  22.       printf ("*****  iscan returned NULL!  *****\n");
  23.     } else {
  24.       printf ("c = [");
  25.       for (i=0; i<7; i++)
  26.         printf (" %4d", c[i]);
  27.       printf ("]\n");
  28.     }
  29.  
  30.     c = iscan (a, 0);
  31.     if (c == NULL) {
  32.       printf ("iscan returned NULL as required.\n");
  33.     } else {
  34.       printf ("*****  iscan failed to return NULL as required.  *****\n");
  35.     }
  36.  
  37.     d = dscan (b, 6);
  38.     if (d == NULL) {
  39.       printf ("*****  dscan returned NULL!  *****\n");
  40.     } else {
  41.       printf ("d = [");
  42.       for (i=0; i<7; i++)
  43.         printf (" %4.1f", d[i]);
  44.       printf ("]\n");
  45.     }
  46.  
  47.     d = dscan (b, 0);
  48.     if (d == NULL) {
  49.       printf ("dscan returned NULL as required.\n");
  50.     } else {
  51.       printf ("*****  dscan failed to return NULL as required.  *****\n");
  52.     }
  53.  
  54. }   
  55.