• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » C++ » Pointer » File Handling in C++
Next →
← Prev

File Handling in C++

By Dinesh Thakur

We know that Files are used for Storing Permanent information. And C++ provides a Facility to a developer the Retrieve the Information from File and he may also modify the Contents of a File So that we can say that File Handling is the Concept to Store, Retrieve and Modify the Information which is stored in the Form of Files in your Computer.

There are Many Built in Classes of C++ , Which Provides Various Functionality for Performing the Operations on Files . A user has a Ability to Modify the data of a File With the help of these Functions. Generally a user can use a File Read, Write or For Appending More data into the File so that C++ Provides Various Classes For Performing these Operations.  There are two most important Classes which are known as ifstream and ofstream. Ifstream stands for input Stream which is used for Reading the Contents from a File and output Stream or Simply ofstream is used for writing data into the Files.

       There is one More Class Which is used for Both Performing read and write known as fstream class and Always Remember for using Any Class First we have to use or include a header file which is called as Fstream.h header file.

Various Functions for Reading and writing data of Files

 
1)   get: – This Functions Stands for Reading data from a File in the Form of Character .

2)   Put :- This Function is used for Writing the data into a File in the Form of Characters

3)      <<  and >> These Operators are also used for Writing the data into the File , The Data may int,float or any other data type  . << Operator is used for Writing data into a File and >> Operator is used for Reading data from a File.  

4) Read and Write: – With the help of C++ one can also Read or Write the Data from a File . But C++ also Provides a Write Method or Function For Writing the data of A Class into a File Like Data of a Member Functions, Values of data Members of a Class and One Can also Read the Information once this written into a File with the help of Read Method or Function.

But Always Remember for reading or Writing data from a Class , first a user have to Explicitly Cast or  Convert  the data of a class in the form of characters because data is written into a File in the Form of Characters and a user have to create some Memory for Specifying how mush data is to be Written into a file and vive-versa for Reading data of a class from a File Whenever a user open a File, The File will Opened and the Pointer of File is stood on first Character or First Line of a File and if a user wants to Read all the data from a File then a user have to use eof () or Simply End of File Functions , a user can read the data until a File doesn’t comes to end A user have also a ability to read data from any Location from a File So that a User have to use Seekg function for Reading data from a Random Position With the help of Seekg function a user can read data from a file , from any position

You’ll also like:

  1. Write a Program to Copy a File using File Handling Functions.
  2. Write a Program to Count Vowels in a File Using File Handling
  3. File Handling in C
  4. File handling in Python
  5. Random File Handling in Java Example
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

C++ Tutorials

C++ Tutorials

  • C++ - Data Types
  • C++ - Operators Types
  • C++ - CPP Program Structure
  • C++ - Conditional Statements
  • C++ - Loop
  • C++ - do-While Loop
  • C++ - Control Statements
  • C++ - Tokens
  • C++ - Jump Statements
  • C++ - Expressions
  • C++ - Constants
  • C++ - Character Set
  • C++ - Iteration Statements
  • C++ - I/O Statements
  • C++ - String
  • C++ - Manipulators

C++ Operator

  • C++ - Input/Output Operator
  • C++ - Operator Overloading

C++ Functions

  • C++ - Functions
  • C++ - Member Functions
  • C++ - Returning Object from Function
  • C++ - Call by Value Vs Reference
  • C++ - Friend Function
  • C++ - Virtual Function
  • C++ - Inline Function
  • C++ - Static Data Members
  • C++ - Static Member Functions

C++ Array & Pointer

  • C++ - Array
  • C++ - Array of Objects
  • C++ - Arrays as Class Members
  • C++ - Vector
  • C++ - Pointer
  • C++ - 'this' Pointer

C++ Classes & Objects

  • C++ - Class
  • C++ - Program Structure With Classes
  • C++ - OOP’s
  • C++ - Objects as Function Arguments
  • C++ - Procedure Vs OOL
  • C++ - Object Vs Class
  • C++ - Creating Objects
  • C++ - Constructors
  • C++ - Copy Constructor
  • C++ - Constructor Overloading
  • C++ - Destructor
  • C++ - Polymorphism
  • C++ - Virtual Base Class
  • C++ - Encapsulation

C++ Inheritance

  • C++ - Inheritance
  • C++ - Multiple Inheritance
  • C++ - Hybrid Inheritance
  • C++ - Abstraction
  • C++ - Overloading

C++ Exception Handling

  • C++ - Exception Handling
  • C++ - Templates
  • C++ - Standard Template Library

C++ Data Structure

  • C++ - Link List

C++ Programs

  • C++ Program for Electricity Bill
  • C++ Program for Multiply Matrices
  • C++ Program for Arithmetic Operators
  • C++ Program For Matrices
  • C++ Program for Constructor
  • C++ Program Verify Number
  • C++ Program Array Of Structure
  • C++ Program to find Average Marks
  • C++ Program Add And Subtract Matrices
  • C++ Program Menu Driven
  • C++ Program To Simple Interest
  • C++ Program To Find Average
  • C++ program exit()
  • C++ Program Using Array Of Objects
  • C++ Program Private Member Function
  • C++ Program To Reverse A String
  • C++ Program to Operator Overloading

Other Links

  • C++ - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW