SlideShare a Scribd company logo
File
• File is a collection of related data stored in a
particular area on the disk
Data communication
• Data transfer between the console unit and
pgm
• Data transfer between pgm and the disk file
If we want use a disk file
1. Suitable name for the file
2. Data type and structure
3. Purpose
4. Opening method
File name
• Is a string of characters
• A valid file name
• It may contain two parts
• Myfile.txt
Data structure
• Crate a file stream using
• Ifstream
• Ofstream
• Fstream
• based on purpose
Purpose/ file modes
• ios::app
• ios::ate
• ios::binary
• ios::in
• ios::nocreate
• ios::noreplace
• ios::out
• ios::trunc
Opening a file
• Using the constructor of either ifstream
ofstream or fstream
• Using the member function open()
Using the constructor of either ifstream
ofstream or fstream
• Ofstream---create output stream
• Ifstream --- create input stream
• Fstream----create input/output stream
• Initialize the file object with the desired name;
• Eg:Ofstream outfile(“result”)
• Ifstream infile(“as.cpp”)
Opening file using open()
• File_stream_class stream_object;
• Stream_object.open(“file_name”)
• Ofstream outfile;
• Outfile.open(“myfile”);
• Stream-object.open(“file name”,mode)
File pointers
• Get pointer
• Put pointer
Functions for manipulation file pointers
• seekg()
• seekp(()
• tellg()
• tellp()

More Related Content

PPT
Filehandlinging cp2
DOCX
Filehandling
PDF
File Handling.pdffile handling ppt final
PPSX
Files in c++
PDF
Filesinc 130512002619-phpapp01
PDF
Data file handling
PPTX
File handling in c++
PDF
Chapter28 data-file-handling
Filehandlinging cp2
Filehandling
File Handling.pdffile handling ppt final
Files in c++
Filesinc 130512002619-phpapp01
Data file handling
File handling in c++
Chapter28 data-file-handling

Similar to The concept of file in C++ programming language (20)

PPTX
pointer, structure ,union and intro to file handling
PDF
Filepointers1 1215104829397318-9
PPTX
Files in c++
PPTX
basics of file handling
PPTX
Basics of file handling
PDF
Files and streams
PDF
file handling c++
PPTX
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handling
PPT
working file handling in cpp overview
PDF
Files in C++.pdf is the notes of cpp for reference
PPTX
Chapter4.pptx
PPT
new pdfrdfzdfzdzzzzzzzzzzzzzzzzzzzzzzzzzzgggggggggggggggggggggggggggggggggggg...
PPTX
Data file operations in C++ Base
PPTX
Working with files in c++. file handling
PPT
File handling in C++
PPT
File handling in_c
pointer, structure ,union and intro to file handling
Filepointers1 1215104829397318-9
Files in c++
basics of file handling
Basics of file handling
Files and streams
file handling c++
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handling
working file handling in cpp overview
Files in C++.pdf is the notes of cpp for reference
Chapter4.pptx
new pdfrdfzdfzdzzzzzzzzzzzzzzzzzzzzzzzzzzgggggggggggggggggggggggggggggggggggg...
Data file operations in C++ Base
Working with files in c++. file handling
File handling in C++
File handling in_c
Ad

Recently uploaded (20)

PPTX
GDM (1) (1).pptx small presentation for students
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Lesson notes of climatology university.
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Classroom Observation Tools for Teachers
PPTX
Cell Types and Its function , kingdom of life
PDF
Computing-Curriculum for Schools in Ghana
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
GDM (1) (1).pptx small presentation for students
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Supply Chain Operations Speaking Notes -ICLT Program
Final Presentation General Medicine 03-08-2024.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Final Presentation General Medicine 03-08-2024.pptx
human mycosis Human fungal infections are called human mycosis..pptx
Lesson notes of climatology university.
A systematic review of self-coping strategies used by university students to ...
Classroom Observation Tools for Teachers
Cell Types and Its function , kingdom of life
Computing-Curriculum for Schools in Ghana
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Module 4: Burden of Disease Tutorial Slides S2 2025
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Ad

The concept of file in C++ programming language

  • 1. File • File is a collection of related data stored in a particular area on the disk
  • 2. Data communication • Data transfer between the console unit and pgm • Data transfer between pgm and the disk file
  • 3. If we want use a disk file 1. Suitable name for the file 2. Data type and structure 3. Purpose 4. Opening method
  • 4. File name • Is a string of characters • A valid file name • It may contain two parts • Myfile.txt
  • 5. Data structure • Crate a file stream using • Ifstream • Ofstream • Fstream • based on purpose
  • 6. Purpose/ file modes • ios::app • ios::ate • ios::binary • ios::in • ios::nocreate • ios::noreplace • ios::out • ios::trunc
  • 7. Opening a file • Using the constructor of either ifstream ofstream or fstream • Using the member function open()
  • 8. Using the constructor of either ifstream ofstream or fstream • Ofstream---create output stream • Ifstream --- create input stream • Fstream----create input/output stream • Initialize the file object with the desired name; • Eg:Ofstream outfile(“result”) • Ifstream infile(“as.cpp”)
  • 9. Opening file using open() • File_stream_class stream_object; • Stream_object.open(“file_name”) • Ofstream outfile; • Outfile.open(“myfile”);
  • 11. File pointers • Get pointer • Put pointer
  • 12. Functions for manipulation file pointers • seekg() • seekp(() • tellg() • tellp()