Jumat, 14 Desember 2018

File Processing

File is a collection of record 
• Record is a collection of field
• Field is a block of byte
-      • Byte is collection of bit

TEXT FILE is saved in a text format or ASCII File.
The syntax is : 
File *fp = fopen ("file_name","value");
Fp is a saving place for file ( it's function is similar with scanf in stdio.h library)

Fopen is use to open file, if some errors occured it will return to 0.

Possible mode value that often used:
r”  opening a file to be read.
  “w”  creating a file to be written.
  “a”  opening a File for data append.
  “r+”  opening a File for read/write.
  “w+”  creating file for read/write.
  “a+”  opening a File for read/append
  “rb”    opening a File (binary) to be read.
  “wb”  creating a file (binary) for write operation

Before using the data, file should be opened using fopen(fp).
After using the data, file should be closed using fclose(fp).

Syntax to input file:
1. fgets
2. fscanf
3. fread

Syntax to output file:
1. fwrite
2. fputs
3. fprintf

Tidak ada komentar:

Posting Komentar