上海交通大学交大密西根 ■■ 联合学院·一 ◆ 18T UM-SJTU Joint Institute ■ University of Michigan Shanghal Jiao Tong University Vg101:Introduction to Computer and Programming Files Records
Vg101:Introduction to Introduction to Computer and Programming Computer and Programming Files & Records
上海交通大学交大密西根 联合学院·一 ◆ 81 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Files Except for a few cases where we generated random data using quasi-random numbers, so far we have only: Input from keyboard and Output to screen This is useful for limited amounts of data. In case of a large quantity of data needs to be handled.We need functions to support input from a file and output to a file
Files • Except for a few cases where we generated random data using quasi-random numbers, so far we have only: – Input from keyboard and – Output to screen • This is useful for limited amounts of data. • In case of a large quantity of data needs to be handled. We need functions to support input from a file and output to a file
上海交通大学交大密西根 联合学院 ■ 81 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University C++'s view of files C++views a file as a sequential stream of bytes. The end of a file is determined anywhere by an end-of-file (EOF)marker,or at a specific byte count that the operating system has been told about in a program. Files are stored permanently by the operating system,usually on a hard-disk or some other medium.The operating system is responsible for the maintenance of files
C++’s view of files s view of files • C++ views a file as a sequential stream of bytes. The end of a file is determined anywhere by an end-of-file (EOF) marker, or at a specific byte count that the operating system has been told about in a program. • Files are stored permanently by the operating system, usually on a hard-disk or some other medium. The operating system is responsible for the maintenance of files
上海交通大学交大密西根 联合学院·一 ◆] 81 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University C++'s view of files The standard header files iostream (keyboard and screen-related Input/Output [I/O)and fstream (file- related 1/O)contains all the stream-file operating system dependencies and has to be rewritten for each new operating system
C++’s view of files s view of files • The standard header files iostream (keyboard and screen-related Input/Output [I/O]) and fstream (filerelated I/O) contains all the stream-file operating system dependencies and has to be rewritten for each new operating system
上海交通大学交大密西根 联合学院·一 ◆ UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Sequential Characteristics One usually uses sequential files for writing and reading data that is not changed later and that is read all at once.It is the most efficient way of storing files which have variable length records. Changing the contents of records or the numbers of records can be done,but not very efficiently. Accessing the contents of some specific records can be done,but not very efficiently
Sequential Characteristics Sequential Characteristics • One usually uses sequential files for writing and reading data that is not changed later and that is read all at once. It is the most efficient way of storing files which have variable length records. • Changing the contents of records or the numbers of records can be done, but not very efficiently. • Accessing the contents of some specific records can be done, but not very efficiently