herophuong

Output test.out

Sep 16th, 2011
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. /*
  2.  * main.c
  3.  *
  4.  *  Created on: Sep 16, 2011
  5.  *      Author: herop-kde
  6.  */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #ifndef __MSDOS__
  10. #include <unistd.h>
  11. #endif __MSDOS__
  12. int main()
  13. {
  14.     int cur_char;
  15.     /* current character to write */
  16.     FILE *out_file; /* output file */
  17.     out_file = fopen("test.out", "w");
  18.     if (out_file == NULL) {
  19.         fprintf(stderr,"Cannot open output file\n");
  20.         exit (8);
  21.     }
  22.     for (cur_char = 0; cur_char < 128; ++cur_char) {
  23.         fputc(cur_char, out_file);
  24.     }
  25.     fclose(out_file);
  26.     return (0);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment