TAILIEUCHUNG - Lecture Elementary programming with C - Session 12: File handling

In this chapter, students will be able to: Explain streams and files, discuss text streams and binary streams, explain the various file functions explain file pointer, discuss current active pointer, explain command-line arguments. | File Handling Session 12 Objectives Explain streams and files Discuss text streams and binary streams Explain the various file functions Explain file pointer Discuss current active pointer Explain command-line arguments File Input/Output All I/O operations in C are carried out using functions from the standard library This approach makes the C file system very powerful and flexible I/O in C is unique because data may be transferred in its internal binary representation or in a human-readable text format Streams The C file system works with a wide variety of devices including printers, disk drives, tape drives and terminals Though all these devices are very different from each other, the buffered file system transforms each device into a logical device called a stream Since all streams act similarly, it is easy to handle the different devices There are two types of streams - the text and binary streams Text Streams A text stream is a sequence of characters that can be organized into lines terminated by a new line character In a text stream, certain character translations may occur as required by the environment Therefore, there may not be a one-to-one relationship between the characters that are written (or read) and those in the external device Also, because of possible translations, the number of characters written (or read) may not be the same as those in the external device Binary Streams A binary stream is a sequence of bytes with a one-to-one correspondence to those in the external device, that is, there are no character translations The number of bytes written (or read) is the same as the number on the external device Binary streams are a flat sequence of bytes, which do not have any flags to indicate the end of file or end of record The end of file is determined by the size of the file Files A file can refer to anything from a disk file to a terminal or a printer A file is associated with a stream by performing an open operation and disassociated by a close

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.