Advertisement
Guest User

1.

a guest
Jan 23rd, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include<stdio.h>
  2. main()
  3. {
  4. FILE *fp;char filename[20];
  5. char ch;
  6. printf("Enter file name : ");
  7. gets(filename);
  8. fp = fopen(filename, "w");
  9. if (fp == NULL)
  10. {
  11. printf("Could not open file ");
  12. }
  13. printf("Enter content to be written in file : ");
  14. while((ch=getchar())!='\n')
  15. {
  16. fputc(ch,fp);
  17. }
  18. fclose(fp);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement