Data files. Leading file ? ? ? ?. Describe internal file) Associate internal file to an external...

10
Algorithms and programming techniques Data files. Leading file ? ? ? ?

Transcript of Data files. Leading file ? ? ? ?. Describe internal file) Associate internal file to an external...

Page 1: Data files. Leading file ? ? ? ?. Describe internal file) Associate internal file to an external file Open the file Access file content (data) Close the.

Algorithms and programming techniques

Data files. Leading file

? ??

?

Page 2: Data files. Leading file ? ? ? ?. Describe internal file) Associate internal file to an external file Open the file Access file content (data) Close the.

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)

Page 3: Data files. Leading file ? ? ? ?. Describe internal file) Associate internal file to an external file Open the file Access file content (data) Close the.

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

Page 4: Data files. Leading file ? ? ? ?. Describe internal file) Associate internal file to an external file Open the file Access file content (data) Close the.

Data files. Leading file

External support

Internal memory

File

Internal record

Currentposition

Processing

Open

Read

Page 5: Data files. Leading file ? ? ? ?. Describe internal file) Associate internal file to an external file Open the file Access file content (data) Close the.

Leading file. General algorithm

START

STOP

! (end processing) Yes

NoProcess current

record

Initial operations

Final operations

Page 6: Data files. Leading file ? ? ? ?. Describe internal file) Associate internal file to an external file Open the file Access file content (data) Close the.

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)

Page 7: Data files. Leading file ? ? ? ?. Describe internal file) Associate internal file to an external file Open the file Access file content (data) Close the.

Leading file. General algorithm – v2

START

STOP

Yes

SF = fread (…)

SF != 0

Final operations

No

Initial operations

Process record

SF = fread (…)

Page 8: Data files. Leading file ? ? ? ?. Describe internal file) Associate internal file to an external file Open the file Access file content (data) Close the.

Leading file. General algorithm – v3

START

STOP

Yes! fread (…)

Final operations

No

Initial operations

Process record

Page 9: Data files. Leading file ? ? ? ?. Describe internal file) Associate internal file to an external file Open the file Access file content (data) Close the.

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

Page 10: Data files. Leading file ? ? ? ?. Describe internal file) Associate internal file to an external file Open the file Access file content (data) Close the.

Spor la învăţat!