thieumao

Đọc ghi file trong C

Apr 6th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. main()
  4. {
  5.  FILE *f;
  6.  char s[50];
  7.  // Tao file moi
  8.  f = fopen("abc.txt","w");
  9.  fprintf(f,"Tao file ne.");
  10.  fclose(f);
  11.  // Doc file
  12.  f = fopen("abc.txt","r");
  13.  fgets(s,50,f);
  14.  printf("%s",s);
  15.  fclose(f);
  16.  // Ghi tiep vao 1 file
  17.  f = fopen("abc.txt","a");
  18.  fprintf(f,"Bo sung ne.");
  19.  fclose(f);
  20.  getch();
  21. }
Advertisement
Add Comment
Please, Sign In to add comment