home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / dos / prg / sphinx / examples / other / create.c__ < prev    next >
Encoding:
Text File  |  1993-04-30  |  1020 b   |  32 lines

  1. /*
  2.     SPHINX C-- example program
  3.     Name:  CREATE.C--
  4.     Description:  This file demonstrates some of the C-- file commands.
  5.                   A file called 'OUTPUT' is created and written to.
  6. */
  7.  
  8. ?include "FILE.H--"
  9. ?include "WRITE.H--"
  10.  
  11. word filehandle;     /* file handle holder */
  12.  
  13. ?define BYTESTOWRITE 12
  14. byte buffer[BYTESTOWRITE]="Hello there!"; /* buffer to be written to file */
  15.  
  16. main ()
  17. {
  18. filehandle = create("OUTPUT",FA_NORMAL);  /* create file with normal attrib's */
  19. IF(filehandle == 0)                    /* if file did not open */
  20.     WRITESTR("Unable to create file.\n"); /* display error message */
  21. ELSE{
  22.     WRITESTR("File created O.K.\n");
  23.     IF( write(filehandle,#buffer,BYTESTOWRITE) != BYTESTOWRITE )
  24.         WRITESTR("Error Writing to file.\n"); 
  25.     ELSE WRITESTR("File written to O.K.\n");
  26.     IF( close(filehandle) == 0 )  /* close the file */
  27.         WRITESTR("File closed O.K.\n");
  28.     ELSE WRITESTR("Error closing file.\n");
  29.     }
  30. }
  31.  
  32. /* end of CREATE.C-- */