TAILIEUCHUNG - A Complete Guide to Programming in C++ part 41

A Complete Guide to Programming in C++ part 41. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | chapter 1 18 Fundamentals of File Input and Output This chapter describes sequential file access using file streams. File streams provide simple and por table file handling techniques. 379 380 CHAPTER 18 FUNDAMENTALS OF FILE INPUT AND OUTPUT FILES File operations FILES 381 When a program is terminated the program data stored in main memory is lost. To store data permanently you need to write that data to a file on an external storage medium. File Operations Single characters or character strings can be written to text files just like they can be output on screen. However it is common practice to store records in files. A record contains data that forms a logical unit such as the human resource information for a person. A write operation stores a record in a file that is the existing record in the file is updated or a new record is added. When you read a record this record is taken from the file and copied to the data structure of a program. Objects can be put into permanent storage using similar techniques. However this normally involves more than just storing an object s data. You also need to ensure that the object can be correctly reconstructed when it is read and this in turn involves storing type information and references to other objects. External mass storage media such as hard disks are normally block-oriented that is data is transferred in blocks whose size is a multiple of 512 bytes. Efficient and easy file management thus implies putting the data you need to store into temporary storage in main memory in a so-called file buffer. File Positions From the viewpoint of a C program a file is simply a long byte array. The structure of the file using records for example is entirely the programmer s responsibility allowing for a maximum degree of flexibility. Every character in a file occupies a byte position. The first byte occupies position 0 the second byte position 1 and so on. The current file position is the position of the byte that will be read or .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.