Slyfoxx724

p8.c

Dec 7th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. 1 #include <stdio.h>
  2. 2
  3. 3 int main(void)
  4. 4 {
  5. 5 FILE *fp_out;
  6. 6
  7. 7 char *str1 = "Four score and seven years ago our";
  8. 8 char *str2 = "fathers brought forth on this continent,";
  9. 9 char *str3 = "a new nation, conceived in Liberty and dedicated";
  10. 10 char *str4 = "to the proposition that all men are created equal.";
  11. 11
  12. 12 fp_out = fopen("my_file", "w");
  13. 13
  14. 14 if(fp_out != NULL)
  15. 15 {
  16. 16 fputs(str1, fp_out);
  17. 17 fputc('\n', fp_out);
  18. 18
  19. 19 fputs(str2, fp_out);
  20. 20 fputc('\n', fp_out);
  21. 21
  22. 22 fputs(str3, fp_out);
  23. 23 fputc('\n', fp_out);
  24. 24
  25. 25 fputs(str4, fp_out);
  26. 26 fputc('\n', fp_out);
  27. 27
  28. 28 fflush(fp_out);
  29. 29 fclose(fp_out);
  30. 30 }
  31. 31 else
  32. 32 printf("I couldn't open the file \"my_file\".\n");
  33. 33
  34. 34 return 0;
  35. 35 }
Add Comment
Please, Sign In to add comment