View
250
Download
0
Category
Tags:
Preview:
Citation preview
Algorithms and programming techniques
Data files. Leading file
? ??
?
Data files. General processing flow
Describe internal file)
Associate internal file to an external
file
Open the file
Access file content (data)
Close the file
Integral / partial
traversing
Direct access
Depends on languageFILE* f;
f=fopen(nume,mod)fopen_s(&f,nume,mod)
Data files. Leading file
Leading file sequential file that directs the processing flow at any given moment only one file may be leading several files may have leading role, but at
different moments
Leading file processing algorithm general processing diagram
Variations of the general algorithm
Data files. Leading file
External support
Internal memory
File
Internal record
Currentposition
Processing
Open
Read
Leading file. General algorithm
START
STOP
! (end processing) Yes
NoProcess current
record
Initial operations
Final operations
Leading file. General algorithm – v1
START
STOP
Yes
Read record
! feof(...)
Read record
Final operations
No
Initial operations
Process record
feof(f) tells the result of the last read from the
file (regarding detection of the end of file)
Leading file. General algorithm – v2
START
STOP
Yes
SF = fread (…)
SF != 0
Final operations
No
Initial operations
Process record
SF = fread (…)
Leading file. General algorithm – v3
START
STOP
Yes! fread (…)
Final operations
No
Initial operations
Process record
Leading file. General algorithm – v4START
STOP
Yesi < nr
Final operations
No
Initial operations
Process record
Compute nr. of records (nr)
i = 0
Read record
i = i+1
Spor la învăţat!
Recommended