SlideShare a Scribd company logo
1 of 35
Download to read offline
DataFileHandling
Prof. K. Adisesha
Learning Outcomes
ī¯ Introduction
ī¯ Stream in C++
ī¯ file stream operation
ī¯ Types of data Files
ī¯ Opening and Closing of Files
ī¯ File Modes
ī¯ Input and Output Operation file
ī¯ File pointers
2
Introduction
File Definition:
3
Introduction
File Definition:
ī¯ A file is a collection of related data stored in a particular
area on the disk.
ī¯ Programs can be designed to perform the read and write
operations on these files.
ī¯ In general a file is a sequence of bits, bytes, lines or
records whose meaning is defined by its user.
ī¯ C++ I/O occurs in streams, which are sequence of bytes.
ī¯ If bytes flows from device like a keyboard, a disk drive,
etc., to main memory, this is called input operation.
4
Stream in C++
Definition:
ī¯ A stream is sequence of bytes. In C++, a stream is a
general name given to flow of data.
ī¯ The three streams in C++ are as follows.
īŽ Input Stream: The stream that supplies data to the
program is known as input stream.
īŽ Output Stream: The stream that receives data from the
program is known as output stream.
īŽ Error Stream: Error streams basically an output stream
used by the programs to the file or on the monitor to report
error messages.
5
File headers
fstream.h header file:
ī¯ The I / O system of C++ contains a set of classes that define
the file handling methods.
ī¯ These include:
īŽ ifstream
īŽ ofstream
īŽ fstream
ī¯ These classes are derived from fstream base and from the
corresponding iostream.h.
ī¯ These classes, designed to manage the disk files, are declared
in fstream.h and therefore we must include this file in any
program that uses files.
6
file stream operation
Classes for file stream:
7
file stream operation
Classes for file stream operation:
8
Class Meanings
filebuf It sets the file buffer to read and write
fstreambase
It serves as a base class for the derived classes ifstream, ofstream
and fstream and contains open( ) and close( ) as member functions
ifstream
It supports input operations.
It contains open( ) with default input mode and inherits get( ),
getline( ), read( ), seekg( ) and tellg( ) functions from istream.
ofstream
It supports output operations.
It contains open( ) with default output mode and inherits put( ),
seekp( ), tellp( ) and write( ) functions from ostream
fstream
It supports simultaneous input and output operations.
It contains open( ) with default input mode and inherits all the
functions from istream and ostream classes through iostream
Types of Files
Types of data Files:
ī¯ Generally there are two types of files in C++:
ī¯ Text Files:
īŽ A text file is a file that stores the information in ASCII
characters.
īŽ Each line of text is terminated by a special character, known as
End of Line (EOL) or delimiter.
ī¯ Binary Files:
īŽ A binary file is a file that contains information in the same
format as it is held in memory.
īŽ In binary files, no delimiters are used for a line and no
translations occur here.
9
Files Operations
Opening Files:
ī¯ A file must first be opened before data can be read from it or
written to it.
ī¯ In C++ there are two ways to open a file with the file stream
object.
īŽ Opening file using constructor.
īŽ Opening file using open ( ) member function.
ī¯ The first method is preferred when a single file is used with a
stream.
ī¯ However for managing multiple files with the same stream, the
second method is preferred.
10
Opening Files
Opening file using constructor:
ī¯ In order to access a file, it has to be opened either in read, write
or append mode.
ī¯ In all the three file stream classes, a file can be opened by
passing a filename as the first parameter in the constructor
itself.
ī¯ The syntax for opening a file using constructor is:
īŽ streamclass_name file_objectname (“filename”)
ī¯ Example:
īŽ ofstream fout (“results.dat”);
īŽ ifstream fin (“results.dat”);
11
Opening Files
Opening files using open( ):
ī¯ open( ) can be used to open multiple files that use the
same stream object.
ī¯ Syntax for opening a file using open ( ) member function:
file_stream_class stream_object;
stream_object.open (“file_name”);
ī¯ Example:
ofstream outfile;
outfile.open (“data”);
outfile.open (“text1.dat”);
12
Opening Files
Opening files using open( ):
ī¯ To open a file for both input and output, we declare
objects of fstream class.
ī¯ Syntax for fstream class using Constructor:
fstream fstream-object(“file name”, mode);
ī¯ syntax for open( ) member function:
fstream-object.open(“file name”, mode);
ī¯ Example:
fstream outfile;
outfile.open (“text1.dat”, mode);
13
File Modes
File Modes:
ī¯ While using constructors or open( ), the files were created
or opened in the default mode.
ī¯ There was only one argument passed, i.e. the filename.
ī¯ C++ provides a mechanism of opening a file in different
modes in which case the second parameter must be
explicitly passed.
ī¯ Syntax:
stream_object.open(“filename”, mode);
ī¯ Example:
fout.open(“data”, ios::app); //opens in append mode
14
File Modes
The lists of file modes are:
15
Mode method Stream Type Meaning
ios::app ofstream append to end of the file at opening time
ios::in ifstream open file for reading
ios::out ofstream open file for writing
ios::ate ifstream Open file for updating and move the file
pointer to the end of file
ios::trunc ofstream On opening, delete the contents of file
ios::nocreate ofstream Turn down opening if the file does not
exists
ios::binary ifstream Opening a binary file.
File Modes
Example of opening file:
16
Closing File
Closing File:
ī¯ The member function close( ) on its execution removes the
linkage between the file and the stream object.
ī¯ Syntax:
stream_object.close( );
ī¯ Example:
ofstream_obj.close( );
ifstream_obj.close( );
17
Operation in text file
Input and output operation in text file:
ī¯ The data in text files are organized into lines with new
line character as terminator.
ī¯ Text file need following types of character input and
output operations:
īŽ put( ) function
īŽ get( ) function
īŽ getline( ) function
18
Text files
put( ) function in text file:
ī¯ The put( ) member function belongs to the class ofstream
and writes single character to the associated stream.
ī¯ Syntax:
ofstream_object.put(ch); // ch is the character variable.
ī¯ Example:
char ch=’A’;
ofstream fout(“text.txt”);
fout.put(ch);
ī¯ fout is the object of ofstream.
ī¯ Text is the name of the file.
ī¯ Value at ch is written to text.
19
Text files
get( ) function in text file:
ī¯ The get( ) member function belong to the class ifstream
and reads a single character from the associated stream.
ī¯ Syntax:
ifstream_object.get (ch); // ch is the character variable.
ī¯ Example:
char ch=’A’;
ifstream fin(“text.txt”);
fin.get (ch);;
ī¯ fin is the object of ifstream.
ī¯ Text is the name of the file.
ī¯ Value at ch is written to text.
20
Text files
getline( ) function in text file:
ī¯ The getline( ) member function belong to the class
ifstream, it reads a whole line from the associated stream.
ī¯ Syntax:
fin.getline(buffer, SIZE)
It reads SIZE characters from the file represented by the object fin or till the
new line character is encountered, whichever comes first into the buffer.
ī¯ Example:
char Student[SIZE];
ifstream fin;
fin.getline (Student, SIZE);
21
Binary files
Input and output operation in binary files:
ī¯ Binary files are very much use when we have to deal with
database consisting of records.
ī¯ The binary format is more accurate for storing the
numbers as they are stored in the exact internal
representation.
ī¯ There is no conversion while saving the data and hence it
is faster.
ī¯ Functions used to handle data in binary form are:
īŽ write ( ) member function.
īŽ read ( ) member function
22
Binary files
write ( ) member function in binary files:
ī¯ The write( ) member function belongs to the class ofstream and
which is used to write binary data to a file.
ī¯ These functions take 2 arguments.
īŽ First is the address of the variable
īŽ Second the size of the variable in bytes.
ī¯ Syntax:
ofstream_object.write((char *) & variable, sizeof(variable));
īŽ The address of the variable must be type casted to pointer to character.
ī¯ Example: student s;
ofstream fout(“std.dat”, ios::binary);
fout.write((char *) &s, sizeof(s));
23
Binary files
Detecting End of file eof( ):
ī¯ Detecting end of file is necessary for preventing any further
attempt to read data from the file.
ī¯ eof( ) is a member function of ios class.
ī¯ It returns a non-zero (true) value if the end of file condition is
encountered while reading; otherwise returns a zero (false).
ī¯ Example:
ifstream fin;
if(fin.eof( ))
{ statements; }
īŽ This is used to execute set statements on reaching the end of the file by
the object fin.
24
File pointers
File pointers and their manipulation:
ī¯ In C++, the file I/O operations are associated with the two
file pointers:
īŽ Input pointer (get pointer)
īŽ Output pointer (put pointer)
ī¯ We use these pointers to move through files while reading
or writing.
ī¯ Each time an input or output operation takes place,
appropriate pointer is automatically advanced.
25
File pointers
File pointers and their manipulation:
ī¯ There are three modes under which we can open a file:
īŽ Read only mode:
īŽ Write only mode
īŽ Append mode
ī¯ When a file is opened in read only mode, the input pointer is
automatically set at the beginning of the file.
ī¯ When a file is opened in write only mode, the existing
contents are deleted and output pointer is set at the beginning
ī¯ If we want to open an existing file to add more data, the file is
opened in append mode. This moves the file pointer to the end
of the file.
26
File pointers
Functions for manipulation of file pointers:
ī¯ To move file pointers to any desired position inside a file,
file stream classes support the following functions:
īŽ seekg() - Moves get file pointer to a specific location
īŽ seekp() - Moves put file pointer to a specific location
īŽ tellg() - Returns the current position of the get pointer
īŽ tellp() - Returns the current position of the put pointer
ī¯ The seekp() and tellp() are member functions of ofstream
ī¯ The seekg() and tellg() are member functions of ifstream.
ī¯ All four functions are available in the class fstream. 27
File pointers
seekg( ) file pointers:
28
File pointers
seekg(offset, seekdir) file pointers:
ī¯ The seekg(offset, seekdir) has two arguments: offset and
seekdir.
ī¯ The offset indicates the number of bytes the get pointer is to be
moved from seekdir position.
ī¯ Syntax:
stream_objectname.seekg(offset, origin_value);
ī¯ Example:
29
seekg( ) function option Action performed
object.seekg(0, ios::beg) Take get pointer to the beginning of the file
object.seekg(0, ios::cur) Stay get pointer at the current position.
object.seekg(-m, ios::end) Go backward by m bytes from the file end.
File pointers
seekg(offset, seekdir) file pointers:
30
File pointers
seekp() file pointers:
ī¯ Move the put pointer to a specified location from the beginning
of a file.
ī¯ There are two types:
īŽ seekp(long);
īŽ seekp(offset, seekdir);
ī¯ The seekp(long) moves the put pointer to a specified location
from the beginning of a file.
ī¯ Example:
infile.seekp(20);
31
File pointers
tellg ( ) and tellp( )file pointers:
ī¯ tellg( ) returns the current position of the get pointer.
ī¯ Syntax:
position = ifstream_object.tellg( );
ī¯ Example:
int position= fin.tellg();
ī¯ tellp( ) returns the current position of the put pointer.
ī¯ Syntax:
position = ifstream_object.tellp( );
ī¯ Example:
int position = fin.tellp();
32
File pointers
tellp( )file pointers:
33
File pointers
Functions for Manipulation of file pointers:
34
Operation on binary file
Basic operation on binary file in C++:
ī¯ Searching
ī¯ Appending data
ī¯ Inserting data in sorted files
ī¯ Deleting a record
ī¯ Modifying data.
35

More Related Content

What's hot

Structure in c
Structure in cStructure in c
Structure in cPrabhu Govind
 
Strings in c++
Strings in c++Strings in c++
Strings in c++Neeru Mittal
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Languagesatvirsandhu9
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructorsVineeta Garg
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++ Hridoy Bepari
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++Vineeta Garg
 
Pointers and Dynamic Memory Allocation
Pointers and Dynamic Memory AllocationPointers and Dynamic Memory Allocation
Pointers and Dynamic Memory AllocationRabin BK
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and stringsRai University
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++sai tarlekar
 
Functions in c language
Functions in c language Functions in c language
Functions in c language tanmaymodi4
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in CSmit Parikh
 
Array of objects.pptx
Array of objects.pptxArray of objects.pptx
Array of objects.pptxRAGAVIC2
 
C Programming: Structure and Union
C Programming: Structure and UnionC Programming: Structure and Union
C Programming: Structure and UnionSelvaraj Seerangan
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdfDurga Padma
 
Type casting in java
Type casting in javaType casting in java
Type casting in javaFarooq Baloch
 
Unit 9. Structure and Unions
Unit 9. Structure and UnionsUnit 9. Structure and Unions
Unit 9. Structure and UnionsAshim Lamichhane
 

What's hot (20)

Structure in c
Structure in cStructure in c
Structure in c
 
Constructor
ConstructorConstructor
Constructor
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
File in C language
File in C languageFile in C language
File in C language
 
Structure in C language
Structure in C languageStructure in C language
Structure in C language
 
Pointers and Dynamic Memory Allocation
Pointers and Dynamic Memory AllocationPointers and Dynamic Memory Allocation
Pointers and Dynamic Memory Allocation
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and strings
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in C
 
Array of objects.pptx
Array of objects.pptxArray of objects.pptx
Array of objects.pptx
 
C Programming: Structure and Union
C Programming: Structure and UnionC Programming: Structure and Union
C Programming: Structure and Union
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
Unit 9. Structure and Unions
Unit 9. Structure and UnionsUnit 9. Structure and Unions
Unit 9. Structure and Unions
 

Similar to Data file handling

chapter-12-data-file-handling.pdf
chapter-12-data-file-handling.pdfchapter-12-data-file-handling.pdf
chapter-12-data-file-handling.pdfstudy material
 
File management in C++
File management in C++File management in C++
File management in C++apoorvaverma33
 
Files in C++.pdf is the notes of cpp for reference
Files in C++.pdf is the notes of cpp for referenceFiles in C++.pdf is the notes of cpp for reference
Files in C++.pdf is the notes of cpp for referenceanuvayalil5525
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))Papu Kumar
 
File handling in_c
File handling in_cFile handling in_c
File handling in_csanya6900
 
basics of file handling
basics of file handlingbasics of file handling
basics of file handlingpinkpreet_kaur
 
Basics of file handling
Basics of file handlingBasics of file handling
Basics of file handlingpinkpreet_kaur
 
Filesinc 130512002619-phpapp01
Filesinc 130512002619-phpapp01Filesinc 130512002619-phpapp01
Filesinc 130512002619-phpapp01Rex Joe
 
Chapter28 data-file-handling
Chapter28 data-file-handlingChapter28 data-file-handling
Chapter28 data-file-handlingDeepak Singh
 
FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUSFILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUSVenugopalavarma Raja
 
Filepointers1 1215104829397318-9
Filepointers1 1215104829397318-9Filepointers1 1215104829397318-9
Filepointers1 1215104829397318-9AbdulghafarStanikzai
 
Filehandlinging cp2
Filehandlinging cp2Filehandlinging cp2
Filehandlinging cp2Tanmay Baranwal
 
File Management and manipulation in C++ Programming
File Management and manipulation in C++ ProgrammingFile Management and manipulation in C++ Programming
File Management and manipulation in C++ ProgrammingChereLemma2
 
Input File dalam C++
Input File dalam C++Input File dalam C++
Input File dalam C++Teguh Nugraha
 

Similar to Data file handling (20)

chapter-12-data-file-handling.pdf
chapter-12-data-file-handling.pdfchapter-12-data-file-handling.pdf
chapter-12-data-file-handling.pdf
 
File Handling
File HandlingFile Handling
File Handling
 
File management in C++
File management in C++File management in C++
File management in C++
 
File Handling In C++
File Handling In C++File Handling In C++
File Handling In C++
 
Files in C++.pdf is the notes of cpp for reference
Files in C++.pdf is the notes of cpp for referenceFiles in C++.pdf is the notes of cpp for reference
Files in C++.pdf is the notes of cpp for reference
 
7 Data File Handling
7 Data File Handling7 Data File Handling
7 Data File Handling
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))
 
File handling in_c
File handling in_cFile handling in_c
File handling in_c
 
basics of file handling
basics of file handlingbasics of file handling
basics of file handling
 
Basics of file handling
Basics of file handlingBasics of file handling
Basics of file handling
 
Filesinc 130512002619-phpapp01
Filesinc 130512002619-phpapp01Filesinc 130512002619-phpapp01
Filesinc 130512002619-phpapp01
 
Files in c++
Files in c++Files in c++
Files in c++
 
Chapter28 data-file-handling
Chapter28 data-file-handlingChapter28 data-file-handling
Chapter28 data-file-handling
 
FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUSFILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
 
Filepointers1 1215104829397318-9
Filepointers1 1215104829397318-9Filepointers1 1215104829397318-9
Filepointers1 1215104829397318-9
 
Filehandlinging cp2
Filehandlinging cp2Filehandlinging cp2
Filehandlinging cp2
 
File Management and manipulation in C++ Programming
File Management and manipulation in C++ ProgrammingFile Management and manipulation in C++ Programming
File Management and manipulation in C++ Programming
 
File Handling in C++
File Handling in C++File Handling in C++
File Handling in C++
 
Chapter4.pptx
Chapter4.pptxChapter4.pptx
Chapter4.pptx
 
Input File dalam C++
Input File dalam C++Input File dalam C++
Input File dalam C++
 

More from Prof. Dr. K. Adisesha

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfProf. Dr. K. Adisesha
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaProf. Dr. K. Adisesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfProf. Dr. K. Adisesha
 
Data_structure using C-Adi.pdf
Data_structure using C-Adi.pdfData_structure using C-Adi.pdf
Data_structure using C-Adi.pdfProf. Dr. K. Adisesha
 

More from Prof. Dr. K. Adisesha (20)

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdf
 
Introduction to Computers.pdf
Introduction to Computers.pdfIntroduction to Computers.pdf
Introduction to Computers.pdf
 
R_Programming.pdf
R_Programming.pdfR_Programming.pdf
R_Programming.pdf
 
Scholarship.pdf
Scholarship.pdfScholarship.pdf
Scholarship.pdf
 
Operating System-2 by Adi.pdf
Operating System-2 by Adi.pdfOperating System-2 by Adi.pdf
Operating System-2 by Adi.pdf
 
Operating System-1 by Adi.pdf
Operating System-1 by Adi.pdfOperating System-1 by Adi.pdf
Operating System-1 by Adi.pdf
 
Operating System-adi.pdf
Operating System-adi.pdfOperating System-adi.pdf
Operating System-adi.pdf
 
Data_structure using C-Adi.pdf
Data_structure using C-Adi.pdfData_structure using C-Adi.pdf
Data_structure using C-Adi.pdf
 
JAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdfJAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdf
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
 

Recently uploaded

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
call girls in Kamla Market (DELHI) 🔝 >āŧ’9953330565🔝 genuine Escort Service 🔝✔ī¸âœ”ī¸
call girls in Kamla Market (DELHI) 🔝 >āŧ’9953330565🔝 genuine Escort Service 🔝✔ī¸âœ”ī¸call girls in Kamla Market (DELHI) 🔝 >āŧ’9953330565🔝 genuine Escort Service 🔝✔ī¸âœ”ī¸
call girls in Kamla Market (DELHI) 🔝 >āŧ’9953330565🔝 genuine Escort Service 🔝✔ī¸âœ”ī¸9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)Dr. Mazin Mohamed alkathiri
 
18-04-UA_REPORT_MEDIALITERAĐĄY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAĐĄY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAĐĄY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAĐĄY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 

Recently uploaded (20)

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
call girls in Kamla Market (DELHI) 🔝 >āŧ’9953330565🔝 genuine Escort Service 🔝✔ī¸âœ”ī¸
call girls in Kamla Market (DELHI) 🔝 >āŧ’9953330565🔝 genuine Escort Service 🔝✔ī¸âœ”ī¸call girls in Kamla Market (DELHI) 🔝 >āŧ’9953330565🔝 genuine Escort Service 🔝✔ī¸âœ”ī¸
call girls in Kamla Market (DELHI) 🔝 >āŧ’9953330565🔝 genuine Escort Service 🔝✔ī¸âœ”ī¸
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
18-04-UA_REPORT_MEDIALITERAĐĄY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAĐĄY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAĐĄY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAĐĄY_INDEX-DM_23-1-final-eng.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 

Data file handling

  • 2. Learning Outcomes ī¯ Introduction ī¯ Stream in C++ ī¯ file stream operation ī¯ Types of data Files ī¯ Opening and Closing of Files ī¯ File Modes ī¯ Input and Output Operation file ī¯ File pointers 2
  • 4. Introduction File Definition: ī¯ A file is a collection of related data stored in a particular area on the disk. ī¯ Programs can be designed to perform the read and write operations on these files. ī¯ In general a file is a sequence of bits, bytes, lines or records whose meaning is defined by its user. ī¯ C++ I/O occurs in streams, which are sequence of bytes. ī¯ If bytes flows from device like a keyboard, a disk drive, etc., to main memory, this is called input operation. 4
  • 5. Stream in C++ Definition: ī¯ A stream is sequence of bytes. In C++, a stream is a general name given to flow of data. ī¯ The three streams in C++ are as follows. īŽ Input Stream: The stream that supplies data to the program is known as input stream. īŽ Output Stream: The stream that receives data from the program is known as output stream. īŽ Error Stream: Error streams basically an output stream used by the programs to the file or on the monitor to report error messages. 5
  • 6. File headers fstream.h header file: ī¯ The I / O system of C++ contains a set of classes that define the file handling methods. ī¯ These include: īŽ ifstream īŽ ofstream īŽ fstream ī¯ These classes are derived from fstream base and from the corresponding iostream.h. ī¯ These classes, designed to manage the disk files, are declared in fstream.h and therefore we must include this file in any program that uses files. 6
  • 7. file stream operation Classes for file stream: 7
  • 8. file stream operation Classes for file stream operation: 8 Class Meanings filebuf It sets the file buffer to read and write fstreambase It serves as a base class for the derived classes ifstream, ofstream and fstream and contains open( ) and close( ) as member functions ifstream It supports input operations. It contains open( ) with default input mode and inherits get( ), getline( ), read( ), seekg( ) and tellg( ) functions from istream. ofstream It supports output operations. It contains open( ) with default output mode and inherits put( ), seekp( ), tellp( ) and write( ) functions from ostream fstream It supports simultaneous input and output operations. It contains open( ) with default input mode and inherits all the functions from istream and ostream classes through iostream
  • 9. Types of Files Types of data Files: ī¯ Generally there are two types of files in C++: ī¯ Text Files: īŽ A text file is a file that stores the information in ASCII characters. īŽ Each line of text is terminated by a special character, known as End of Line (EOL) or delimiter. ī¯ Binary Files: īŽ A binary file is a file that contains information in the same format as it is held in memory. īŽ In binary files, no delimiters are used for a line and no translations occur here. 9
  • 10. Files Operations Opening Files: ī¯ A file must first be opened before data can be read from it or written to it. ī¯ In C++ there are two ways to open a file with the file stream object. īŽ Opening file using constructor. īŽ Opening file using open ( ) member function. ī¯ The first method is preferred when a single file is used with a stream. ī¯ However for managing multiple files with the same stream, the second method is preferred. 10
  • 11. Opening Files Opening file using constructor: ī¯ In order to access a file, it has to be opened either in read, write or append mode. ī¯ In all the three file stream classes, a file can be opened by passing a filename as the first parameter in the constructor itself. ī¯ The syntax for opening a file using constructor is: īŽ streamclass_name file_objectname (“filename”) ī¯ Example: īŽ ofstream fout (“results.dat”); īŽ ifstream fin (“results.dat”); 11
  • 12. Opening Files Opening files using open( ): ī¯ open( ) can be used to open multiple files that use the same stream object. ī¯ Syntax for opening a file using open ( ) member function: file_stream_class stream_object; stream_object.open (“file_name”); ī¯ Example: ofstream outfile; outfile.open (“data”); outfile.open (“text1.dat”); 12
  • 13. Opening Files Opening files using open( ): ī¯ To open a file for both input and output, we declare objects of fstream class. ī¯ Syntax for fstream class using Constructor: fstream fstream-object(“file name”, mode); ī¯ syntax for open( ) member function: fstream-object.open(“file name”, mode); ī¯ Example: fstream outfile; outfile.open (“text1.dat”, mode); 13
  • 14. File Modes File Modes: ī¯ While using constructors or open( ), the files were created or opened in the default mode. ī¯ There was only one argument passed, i.e. the filename. ī¯ C++ provides a mechanism of opening a file in different modes in which case the second parameter must be explicitly passed. ī¯ Syntax: stream_object.open(“filename”, mode); ī¯ Example: fout.open(“data”, ios::app); //opens in append mode 14
  • 15. File Modes The lists of file modes are: 15 Mode method Stream Type Meaning ios::app ofstream append to end of the file at opening time ios::in ifstream open file for reading ios::out ofstream open file for writing ios::ate ifstream Open file for updating and move the file pointer to the end of file ios::trunc ofstream On opening, delete the contents of file ios::nocreate ofstream Turn down opening if the file does not exists ios::binary ifstream Opening a binary file.
  • 16. File Modes Example of opening file: 16
  • 17. Closing File Closing File: ī¯ The member function close( ) on its execution removes the linkage between the file and the stream object. ī¯ Syntax: stream_object.close( ); ī¯ Example: ofstream_obj.close( ); ifstream_obj.close( ); 17
  • 18. Operation in text file Input and output operation in text file: ī¯ The data in text files are organized into lines with new line character as terminator. ī¯ Text file need following types of character input and output operations: īŽ put( ) function īŽ get( ) function īŽ getline( ) function 18
  • 19. Text files put( ) function in text file: ī¯ The put( ) member function belongs to the class ofstream and writes single character to the associated stream. ī¯ Syntax: ofstream_object.put(ch); // ch is the character variable. ī¯ Example: char ch=’A’; ofstream fout(“text.txt”); fout.put(ch); ī¯ fout is the object of ofstream. ī¯ Text is the name of the file. ī¯ Value at ch is written to text. 19
  • 20. Text files get( ) function in text file: ī¯ The get( ) member function belong to the class ifstream and reads a single character from the associated stream. ī¯ Syntax: ifstream_object.get (ch); // ch is the character variable. ī¯ Example: char ch=’A’; ifstream fin(“text.txt”); fin.get (ch);; ī¯ fin is the object of ifstream. ī¯ Text is the name of the file. ī¯ Value at ch is written to text. 20
  • 21. Text files getline( ) function in text file: ī¯ The getline( ) member function belong to the class ifstream, it reads a whole line from the associated stream. ī¯ Syntax: fin.getline(buffer, SIZE) It reads SIZE characters from the file represented by the object fin or till the new line character is encountered, whichever comes first into the buffer. ī¯ Example: char Student[SIZE]; ifstream fin; fin.getline (Student, SIZE); 21
  • 22. Binary files Input and output operation in binary files: ī¯ Binary files are very much use when we have to deal with database consisting of records. ī¯ The binary format is more accurate for storing the numbers as they are stored in the exact internal representation. ī¯ There is no conversion while saving the data and hence it is faster. ī¯ Functions used to handle data in binary form are: īŽ write ( ) member function. īŽ read ( ) member function 22
  • 23. Binary files write ( ) member function in binary files: ī¯ The write( ) member function belongs to the class ofstream and which is used to write binary data to a file. ī¯ These functions take 2 arguments. īŽ First is the address of the variable īŽ Second the size of the variable in bytes. ī¯ Syntax: ofstream_object.write((char *) & variable, sizeof(variable)); īŽ The address of the variable must be type casted to pointer to character. ī¯ Example: student s; ofstream fout(“std.dat”, ios::binary); fout.write((char *) &s, sizeof(s)); 23
  • 24. Binary files Detecting End of file eof( ): ī¯ Detecting end of file is necessary for preventing any further attempt to read data from the file. ī¯ eof( ) is a member function of ios class. ī¯ It returns a non-zero (true) value if the end of file condition is encountered while reading; otherwise returns a zero (false). ī¯ Example: ifstream fin; if(fin.eof( )) { statements; } īŽ This is used to execute set statements on reaching the end of the file by the object fin. 24
  • 25. File pointers File pointers and their manipulation: ī¯ In C++, the file I/O operations are associated with the two file pointers: īŽ Input pointer (get pointer) īŽ Output pointer (put pointer) ī¯ We use these pointers to move through files while reading or writing. ī¯ Each time an input or output operation takes place, appropriate pointer is automatically advanced. 25
  • 26. File pointers File pointers and their manipulation: ī¯ There are three modes under which we can open a file: īŽ Read only mode: īŽ Write only mode īŽ Append mode ī¯ When a file is opened in read only mode, the input pointer is automatically set at the beginning of the file. ī¯ When a file is opened in write only mode, the existing contents are deleted and output pointer is set at the beginning ī¯ If we want to open an existing file to add more data, the file is opened in append mode. This moves the file pointer to the end of the file. 26
  • 27. File pointers Functions for manipulation of file pointers: ī¯ To move file pointers to any desired position inside a file, file stream classes support the following functions: īŽ seekg() - Moves get file pointer to a specific location īŽ seekp() - Moves put file pointer to a specific location īŽ tellg() - Returns the current position of the get pointer īŽ tellp() - Returns the current position of the put pointer ī¯ The seekp() and tellp() are member functions of ofstream ī¯ The seekg() and tellg() are member functions of ifstream. ī¯ All four functions are available in the class fstream. 27
  • 28. File pointers seekg( ) file pointers: 28
  • 29. File pointers seekg(offset, seekdir) file pointers: ī¯ The seekg(offset, seekdir) has two arguments: offset and seekdir. ī¯ The offset indicates the number of bytes the get pointer is to be moved from seekdir position. ī¯ Syntax: stream_objectname.seekg(offset, origin_value); ī¯ Example: 29 seekg( ) function option Action performed object.seekg(0, ios::beg) Take get pointer to the beginning of the file object.seekg(0, ios::cur) Stay get pointer at the current position. object.seekg(-m, ios::end) Go backward by m bytes from the file end.
  • 31. File pointers seekp() file pointers: ī¯ Move the put pointer to a specified location from the beginning of a file. ī¯ There are two types: īŽ seekp(long); īŽ seekp(offset, seekdir); ī¯ The seekp(long) moves the put pointer to a specified location from the beginning of a file. ī¯ Example: infile.seekp(20); 31
  • 32. File pointers tellg ( ) and tellp( )file pointers: ī¯ tellg( ) returns the current position of the get pointer. ī¯ Syntax: position = ifstream_object.tellg( ); ī¯ Example: int position= fin.tellg(); ī¯ tellp( ) returns the current position of the put pointer. ī¯ Syntax: position = ifstream_object.tellp( ); ī¯ Example: int position = fin.tellp(); 32
  • 34. File pointers Functions for Manipulation of file pointers: 34
  • 35. Operation on binary file Basic operation on binary file in C++: ī¯ Searching ī¯ Appending data ī¯ Inserting data in sorted files ī¯ Deleting a record ī¯ Modifying data. 35