home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / R_LA4_02.ZIP / WRITES.C < prev   
Encoding:
C/C++ Source or Header  |  1987-12-30  |  539 b   |  21 lines

  1. /* WRITES.C - From page 437 of "Microsoft C Programming for     */
  2. /* the IBM" by Robert Lafore. Writes the file C:TEXTFILE.TXT,   */
  3. /* typed at keyboard, to disk.                                  */
  4. /****************************************************************/
  5.  
  6. #include <stdio.h>
  7.  
  8. main()
  9. {
  10. FILE *fptr;
  11. char string[81];
  12.  
  13.    fptr = fopen("c:textfile.txt", "w");
  14.    while(strlen(gets(string)) > 0) {
  15.       fputs(string, fptr);             /*write string to file*/
  16.       fputs("\n", fptr);
  17.    }
  18.    fclose(fptr);
  19. }
  20.  
  21.