Home » Learn C++ » Data Files in C++

Data Files in C++

Data Files in C++

The input was given from the keyboard and the output was received on the computer screen. This method works well when input and output are not many and are small. But when the input becomes large, it is not possible to enter data from the keyboard. If there is a mistake in entering data, all data will have to be entered again. Similarly, if the output is large, it is necessary to keep it permanently stored on the disk for future use.

The data files provide a solution to this problem. The file saved on the disk is used to give input into the program. The input data is written in the file. The program reads the data from the file. Similarly, the program writes the output in a file on the disk. The output written in the file can then be displayed and/or printed on the printer.

File handling in C++ is quite different from that in procedural languages. C++ provides an easy method of file handling. In procedural languages, files are processed on the disk by using functions but in C++, objects are used for the same purpose.

Terminology Used for Data Files

Before discussing tile-handling techniques in C++, it is important to understand the following basic terms used in input/output tiles:

cplusplus

CHARACTERS: Characters consist of alphabets, digits and special characters. These are represented inside the computer as a sequence of 1s and 0s. It requires 8 hits (one byte) to store one character.

FIELDS: A group of characters or bytes that represents a piece of data is called field. For example, in a file, the name of a person represents one field. Similarly, home address represents another field.

RECORD: A group of related fields is called record.

FILE: A group of related records is called a file.

The data or records in tiles can be organized into different ways. In C++, files are processed into two ways:

  • Formatted input/output
  • Binary input/output

Other Topics

comment closed

Get Adobe Flash playerPlugin by wpburn.com wordpress themes
Copyright © 2010 Information Village. All rights reserved.