Advertisement
Guest User

File creation and adding contents

a guest
Apr 27th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.26 KB | None | 0 0
  1. //Create a file with contents
  2. #include<stdio.h>
  3. #include<conio.h>
  4. void main()
  5. {
  6.  FILE *test;
  7.  char *str;
  8.  test=fopen("test.txt","w+");
  9.  fputs("This is the text stored in test.txt",test);
  10.  if(fgets(str,60,test)!=NULL)
  11.  puts(str);
  12.  fclose(test);
  13.  getch();
  14.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement