SlideShare a Scribd company logo
1 of 10
SUBJECT :- Object Oriented Programming with C++
TOPIC :- File Management Functions
Prepared by: Vaani Pathak
Branch: CE
Division: B3
Enrollment No.: 170120107131
Guided by: Utsav Shah
Introduction
Gandhinagar Institute Of Technology2
 In Files we store data i.e. text or binary data
permanently and use these data to read or write in
the form of input output operations by transferring
bytes of data.
 So we use the term File Streams/File handling.
 We use the header file <fstream>
Header file
Gandhinagar Institute Of Technology3
 ofstream: It represents output Stream and this is
used for writing in files.
 ifstream: It represents input Stream and this is used
for reading from files.
 fstream: It represents both output Stream and input
Stream. So it can read from files and write to files.
Operations in File Management
Gandhinagar Institute Of Technology 4
 Below the operations used for file management in
c++
o Creating a file: open()
o Reading data: read()
o Writing new data: write()
o Closing a file: close()
Creating/Opening a File
Gandhinagar Institute Of Technology5
 A file must be opened before you can read from it or
write
 Here, the first argument specifies the name and
location of the file to be opened and the second
argument of the open() member function defines the
mode in which the file should be opened.
o void open(const char *filename, ios::openmode mode);
Types:
Gandhinagar Institute Of Technology6
File opened for writing ios::out
File opened for reading ios::in
File opened for appending ios::app
File opened for truncating ios::trunc
Reading from a File
Gandhinagar Institute Of Technology7
 You read information from a file into your program
using the stream extraction operator (>>) just as you
use that operator to input information from the
keyboard.
 The only difference is that you use
an ifstream or fstream object instead of
the cin object.
Writing to a File
Gandhinagar Institute Of Technology8
 While doing C++ programming, you write information
to a file from your program using the stream insertion
operator (<<) just as you use that operator to output
information to the screen.
 The only difference is that you use
an ofstream or fstream object instead of
the cout object.
Closing a File
Gandhinagar Institute Of Technology9
 When a C++ program terminates it automatically
flushes all the streams, release all the allocated
memory and close all the opened files.
 But it is always a good practice that a programmer
should close all the opened files before program
termination.
 Following is the standard syntax for close() function,
which is a member of fstream, ifstream, and
ofstream objects.
THANK YOU

More Related Content

What's hot

Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysisIffat Anjum
 
Finalize() method
Finalize() methodFinalize() method
Finalize() methodJadavsejal
 
Informed search (heuristics)
Informed search (heuristics)Informed search (heuristics)
Informed search (heuristics)Bablu Shofi
 
Samsung processors: Exynos family
Samsung processors: Exynos familySamsung processors: Exynos family
Samsung processors: Exynos familySagar Patel
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 
Css color and background properties
Css color and background propertiesCss color and background properties
Css color and background propertiesJesus Obenita Jr.
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C LanguageSurbhi Yadav
 
INTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third EditionINTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third EditionPHI Learning Pvt. Ltd.
 
LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)wahab khan
 
Symbol table management and error handling in compiler design
Symbol table management and error handling in compiler designSymbol table management and error handling in compiler design
Symbol table management and error handling in compiler designSwati Chauhan
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligencelordmwesh
 

What's hot (20)

Id and class selector
Id and class selectorId and class selector
Id and class selector
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
 
Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysis
 
File Handling In C++
File Handling In C++File Handling In C++
File Handling In C++
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Finalize() method
Finalize() methodFinalize() method
Finalize() method
 
Informed search (heuristics)
Informed search (heuristics)Informed search (heuristics)
Informed search (heuristics)
 
Samsung processors: Exynos family
Samsung processors: Exynos familySamsung processors: Exynos family
Samsung processors: Exynos family
 
Automaton
AutomatonAutomaton
Automaton
 
Symbol Table
Symbol TableSymbol Table
Symbol Table
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Lexical analysis-using-lex
Lexical analysis-using-lexLexical analysis-using-lex
Lexical analysis-using-lex
 
Css color and background properties
Css color and background propertiesCss color and background properties
Css color and background properties
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 
INTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third EditionINTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third Edition
 
LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)
 
Problem Solving
Problem Solving Problem Solving
Problem Solving
 
Symbol table management and error handling in compiler design
Symbol table management and error handling in compiler designSymbol table management and error handling in compiler design
Symbol table management and error handling in compiler design
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligence
 

Similar to file management functions

Similar to file management functions (20)

C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
 
Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes 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
 
Chapter4.pptx
Chapter4.pptxChapter4.pptx
Chapter4.pptx
 
File handling in cpp
File handling in cppFile handling in cpp
File handling in cpp
 
File handling
File handlingFile handling
File handling
 
File management in C++
File management in C++File management in C++
File management in C++
 
Streams and Files
Streams and FilesStreams and Files
Streams and Files
 
Basics of files and its functions with example
Basics of files and its functions with exampleBasics of files and its functions with example
Basics of files and its functions with example
 
File in cpp 2016
File in cpp 2016 File in cpp 2016
File in cpp 2016
 
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 Handling
File HandlingFile Handling
File Handling
 
File handling in_c
File handling in_cFile handling in_c
File handling in_c
 
Data file handling
Data file handlingData file handling
Data file handling
 
Files in c++ ppt
Files in c++ pptFiles in c++ ppt
Files in c++ ppt
 
Pf cs102 programming-8 [file handling] (1)
Pf cs102 programming-8 [file handling] (1)Pf cs102 programming-8 [file handling] (1)
Pf cs102 programming-8 [file handling] (1)
 
7 Data File Handling
7 Data File Handling7 Data File Handling
7 Data File Handling
 
VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5
 

More from vaani pathak

D’Alembert’s Solution of the Wave Equation
D’Alembert’s Solution of the Wave EquationD’Alembert’s Solution of the Wave Equation
D’Alembert’s Solution of the Wave Equationvaani pathak
 
Dynamic Memory Allocation
Dynamic Memory AllocationDynamic Memory Allocation
Dynamic Memory Allocationvaani pathak
 
interpolation of unequal intervals
interpolation of unequal intervalsinterpolation of unequal intervals
interpolation of unequal intervalsvaani pathak
 
Arc Length, Curvature and Torsion
Arc Length, Curvature and TorsionArc Length, Curvature and Torsion
Arc Length, Curvature and Torsionvaani pathak
 
Fixtures and Reflectors
Fixtures and ReflectorsFixtures and Reflectors
Fixtures and Reflectorsvaani pathak
 
Calculus ppt format
Calculus ppt formatCalculus ppt format
Calculus ppt formatvaani pathak
 
Planning for presentation
Planning for presentationPlanning for presentation
Planning for presentationvaani pathak
 
Types of polarisation
Types of polarisationTypes of polarisation
Types of polarisationvaani pathak
 
Air Pollution Acts
Air Pollution ActsAir Pollution Acts
Air Pollution Actsvaani pathak
 

More from vaani pathak (15)

D’Alembert’s Solution of the Wave Equation
D’Alembert’s Solution of the Wave EquationD’Alembert’s Solution of the Wave Equation
D’Alembert’s Solution of the Wave Equation
 
Dynamic Memory Allocation
Dynamic Memory AllocationDynamic Memory Allocation
Dynamic Memory Allocation
 
error detection
error detectionerror detection
error detection
 
interpolation of unequal intervals
interpolation of unequal intervalsinterpolation of unequal intervals
interpolation of unequal intervals
 
Arc Length, Curvature and Torsion
Arc Length, Curvature and TorsionArc Length, Curvature and Torsion
Arc Length, Curvature and Torsion
 
Cpd 4.2
Cpd 4.2Cpd 4.2
Cpd 4.2
 
CPD ch 7
CPD ch 7CPD ch 7
CPD ch 7
 
Chain Drive
Chain DriveChain Drive
Chain Drive
 
AM FM PM
AM FM PMAM FM PM
AM FM PM
 
Fixtures and Reflectors
Fixtures and ReflectorsFixtures and Reflectors
Fixtures and Reflectors
 
Calculus ppt format
Calculus ppt formatCalculus ppt format
Calculus ppt format
 
Planning for presentation
Planning for presentationPlanning for presentation
Planning for presentation
 
Types of polarisation
Types of polarisationTypes of polarisation
Types of polarisation
 
CPU Algorithm
CPU Algorithm CPU Algorithm
CPU Algorithm
 
Air Pollution Acts
Air Pollution ActsAir Pollution Acts
Air Pollution Acts
 

Recently uploaded

Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 

Recently uploaded (20)

Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 

file management functions

  • 1. SUBJECT :- Object Oriented Programming with C++ TOPIC :- File Management Functions Prepared by: Vaani Pathak Branch: CE Division: B3 Enrollment No.: 170120107131 Guided by: Utsav Shah
  • 2. Introduction Gandhinagar Institute Of Technology2  In Files we store data i.e. text or binary data permanently and use these data to read or write in the form of input output operations by transferring bytes of data.  So we use the term File Streams/File handling.  We use the header file <fstream>
  • 3. Header file Gandhinagar Institute Of Technology3  ofstream: It represents output Stream and this is used for writing in files.  ifstream: It represents input Stream and this is used for reading from files.  fstream: It represents both output Stream and input Stream. So it can read from files and write to files.
  • 4. Operations in File Management Gandhinagar Institute Of Technology 4  Below the operations used for file management in c++ o Creating a file: open() o Reading data: read() o Writing new data: write() o Closing a file: close()
  • 5. Creating/Opening a File Gandhinagar Institute Of Technology5  A file must be opened before you can read from it or write  Here, the first argument specifies the name and location of the file to be opened and the second argument of the open() member function defines the mode in which the file should be opened. o void open(const char *filename, ios::openmode mode);
  • 6. Types: Gandhinagar Institute Of Technology6 File opened for writing ios::out File opened for reading ios::in File opened for appending ios::app File opened for truncating ios::trunc
  • 7. Reading from a File Gandhinagar Institute Of Technology7  You read information from a file into your program using the stream extraction operator (>>) just as you use that operator to input information from the keyboard.  The only difference is that you use an ifstream or fstream object instead of the cin object.
  • 8. Writing to a File Gandhinagar Institute Of Technology8  While doing C++ programming, you write information to a file from your program using the stream insertion operator (<<) just as you use that operator to output information to the screen.  The only difference is that you use an ofstream or fstream object instead of the cout object.
  • 9. Closing a File Gandhinagar Institute Of Technology9  When a C++ program terminates it automatically flushes all the streams, release all the allocated memory and close all the opened files.  But it is always a good practice that a programmer should close all the opened files before program termination.  Following is the standard syntax for close() function, which is a member of fstream, ifstream, and ofstream objects.