File Processing:
–Files and Streams
–File Definition
–Open File
–Close File
–Input File
–Output File
File & Stream
– File is collection of record (baris),is block of byte
– Record is collection of field (kolom),is collection of bit
1 byte = 8 bit
-Field is a block of byte
-Byte is collection of bit
Definisi Streams
- To keep key in data from keyboard need to be saved at secondary storage device as a data file.
- Streamis a sequence of character. All input and output data is a stream. C sees file as a stream.
3 Jenis Stream :
- Standard Input Stream
Controlling input stream from keyboard
- Standard Output Stream
Controlling output stream to the monitor
- Standard Error Stream
Controlling the error messaging
Buffer area
FILE *fp -> boleh ada boleh tidak
OPEN FILE
FILE *fopen
r -> READ
w -> Tulis
a -> Nambahin data , dibelakang
r+ -> buka data untuk ditulis dan dibaca
w+ -> buat data untuk tulis dan baca
a+ -> buka data untuk baca atau tambah
Close File
int fclose(FILE *stream)
– defined at stdio.h
-EOF equals -1
-Ditutup agar aplikasi lain bisa melihat