-moz-user-select:none; -webkit-user-select:none; -khtml-user-select:none; -ms-user-select:none; user-select:none;

Saturday, 23 January 2016

Concept of files in C++

Many students are confused with the concept of file handling in C++.So,today I will give you a little introduction about the concept of files in C++ which the essence of file handling.This would be a series of blogs which will help you to understand this concept easily.So,stay tuned !!1

Concept of files

As we see that a program inputs data from the user and stores it in variables.The data stored in the variables is temporary.When the program ends,all data stored in variables is also destroyed. The user has  to input data again from keyboard when the program is executed next time. the data has to be entered each time the program is executed that wastes time. The user may also type wrong data at different times.

Definition of files

A file is a collection of related records.It stores data about an entity(if you are unfamiliar with the concept of entity, remember that an entity is an object about which data is to be gathered.e.g., student is an entity). A data file can be used to provide input to a program.In can also be used to store the output of a program permanently.


Advantages of files

Now we will discuss the advantages of files in C++.

  • Files can store large amount of data permanently.
  • Files can be updated easily.
  • One file can be used by many programs for same input.
  • Files save time and effort to input data via keyboard.

Types of files

C++ provides two types of files.This categorization is based on how data is stored in files. Following are the types of files in C++.

Text files

A type of file that stores data as readable and printable characters in called text file.A source program of C++ is an example of text file.


Binary files

A type of file that stores data as non-readable binary code is called binary file.An object file of a C++ program is an example of binary file.


Reference

This reference of this article is taken from the book,Object Oriented Programming using C++(IT series).

2 comments: