home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / dos / prg / sphinx / examples / other / files.c__ < prev    next >
Encoding:
Text File  |  1993-05-14  |  933 b   |  29 lines

  1. /*
  2.     SPHINX C-- example program of file commands 
  3. */
  4.  
  5. ?include "WRITE.H--"
  6.  
  7. word filehandle;  /* file handle holder */
  8.  
  9. ?define BYTESTOREAD  5000    /* number of bytes to read from file */   
  10. byte read[BYTESTOREAD+1];    /* buffer to hold bytes read from file */
  11.  
  12.  
  13. main ()
  14. {
  15. filehandle = FOPEN(0, , ,"FILES.C--");   /* open file */
  16. IF(filehandle == 0)                    /* if file did not open */
  17.     WRITESTR("ERROR, file did not open.\n"); /* display error message */
  18. ELSE{WRITESTR("File OPENED O.K.\n");
  19.     WRITESTR("displaying file:\n"); 
  20.     AX = FREAD( ,filehandle,BYTESTOREAD,#read); /* read 5000 bytes from file */
  21.     BX = AX;
  22.     read[BX] = 0;          /* put a 0 terminator at the end of the bytes read */
  23.     FCLOSE( ,filehandle);  /* close the file */
  24.     WRITESTR(#read,0);  /* print read bytes to screen */
  25.     }
  26. @ GETCH();   /* Wait for a key to be pressed */
  27. }
  28.  
  29. /* end of FILES.C-- */