home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / SRC.DI$ / MATTEST7.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-26  |  692 b   |  41 lines

  1. /*
  2.  *    MATTEST7
  3.  *
  4.  *    Simple program that illustrates how to call the MAT-file Library
  5.  *    from a C program.  
  6.  *
  7.  *    The example prints out a directory of the Matrix names contained
  8.  *    within a MAT-file.
  9.  *    
  10.  */
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include "mat.h"
  14.  
  15. main()
  16. {
  17.     MATFile *fp;
  18.     char    **dir;
  19.     int     ndir, i;
  20.  
  21.     fp = matOpen("foo.mat", "r");
  22.     if (fp == NULL) {
  23.         printf("Can't open mat file foo.mat for reading\n");
  24.         exit(1);
  25.     }
  26.     dir = matGetDir(fp, &ndir);
  27.     matClose(fp);
  28.  
  29.     if (dir == NULL) {
  30.         printf("Can't read directory\n");
  31.         exit(1);
  32.     } else {
  33.         printf("Directory of MAT-file:\n");
  34.         for (i=0; i < ndir; i++) {
  35.             printf("%s\n",dir[i]);
  36.         }
  37.     }
  38.     mxFree(dir);
  39.     exit(0);
  40. }
  41.