Download presentation
Presentation is loading. Please wait.
Published byFlorence Carpenter Modified over 9 years ago
1
TEXT FILES
2
Text Files Files Data saved in external storage and can be referenced by a single name File types Document, image, audio, video, etc. Program files, data files Source code, object code, executable code File types Text files – can be read without special program (.txt,.dat) Binary files – requires special programs for reading (.exe,.jpg,.docx, etc)
3
File Processing Open Make connection between external file and internal file object Process Read into buffer Write to buffer Close Sever connection between external file and internal file object Empty buffer
4
Reading from File #include #include // for ifstream #include using namespace std; int main() { ifstream inf; string name; int age; // Open file inf.open("myFile.txt"); // Read data and output to console while (!inf.eof()) { inf >> name; inf >> age; cout << name << " is " << age << " years old.\n"; } return 0; } Anne 25 Ben 15 Cathy 21 Donald 25 Eddy 29 myFile.txt
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.