Đang chuẩn bị liên kết để tải về tài liệu:
Tìm hiểu hàm và thư viện lập trình phần 9

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Ghi dữ liệu ra tệp tin — Tương tự như sử dụng cout — Tệp tin có thể chứa dữ liệu kiểu hỗn hợp, ví dụ: fout | 3.6 Làm việc với tệp tin trong C include iostream.h include fstream.h Khai báo một biến ifstream fin input ofstream fout output fstream fio input and output Mở tạo một tệp tin fin. open file1.txt fout.open file2.dat fio. open file3.inf Kết hợp khai báo biến và mở tạo một tệp tin ifstream fin file1.txt input ofstream fout file2.inf output fstream fio file3.dat input and output Chương 3 Hàm và thư viện Ghi dữ liệu ra tệp tin - Tương tự như sử dụng cout - Tệp tin có thể chứa dữ liệu kiểu hỗn hợp ví dụ fout Nguyen Van A endl fout 21 endl false Đọc dữ liệu từ một tệp tin Tương tự như sử dụng cin char name 32 int age married fin.getline name 32 fin age married Đóng một tệp tin Tự động khi kết thúc phạm vi Hoặc gọi hàm thành viên close fin. close fout.close fio. close Chương 3 Hàm và thư viện Ví dụ làm việc với tệp tin include iostream.h include fstream.h void main ofstream fout file1.dat output fout Nguyen Van A endl 21 endl false ifstream fin file1.dat input char name 32 int age int married fin.getline name 32 fin age married cout Name t name endl cout Age t age endl cout Married married Yes No char c cin c Chương 3 Hàm và thư .