Aim : Write a program that creates a binary file by reading the data for the students from the terminal. The data of each student consists of roll number, name (a string of 30 or less number of characters) and marks

Theory

1.Array of Object:

An array in C/C++ or be it in any programming language is a collection of similar data items stored at contiguous memory locations and elements can be accessed randomly using indices of an array. They can be used to store the collection of primitive data types such as int, float, double, char, etc of any particular type. To add to it, an array in C/C++ can store derived data types such as structures, pointers, etc. Given below is the picture representation of an array.
Syntax:
ClassName ObjectName[number of objects];

2.File Handling

File handling is used to store data permanently in a computer. Using file handling we can store our data in secondary memory (Hard disk).
How to achieve the File Handling
For achieving file handling we need to follow the following steps:-
STEP 1-Naming a file
STEP 2-Opening a file
STEP 3-Writing data into the file
STEP 4-Reading data from the file
STEP 5-Closing a file.
Classes for File stream operations :-
1. ios:- ios stands for input output stream.
2. istream:- istream stands for input stream.
3. ostream:-ostream stands for output stream.
4. streambuf:-This class contains a pointer which points to the buffer which is used to manage the input and output streams
5.ifstream:-This class provides input operations.
6.ofstream:-This class provides output operations.
7.fstream:-This class provides support for simultaneous input and output operations.
9. filebuf:-Its purpose is to set the file buffers to read and write.
Program :

Conclusion : Hence we have performed our practical successfully