Advertisement
NightRaven97

File creation and adding contents

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