Random access in File Handling Using C++ Programming Language
This project is based on Random access in File Handling to enter users data in random and to search them. Here I have written code for finding the train number and details of it Using C++ program
Definition:
Random access means you can move to any part of a file and read or write data from it without having to read through the entire file.
ALGORITHM:
- Start
- Define class train
- Read and print the train details using get() and print()
- main()
- Open file in write mode
- If in==NULL. Print error in creating file otherwise goto 7
- Call get()
- Enter the data into the file
- If the user wishes to continue repeat steps 7 and 8
- Open the file in read mode
- Enter the train no to be searched
- Use seekg()
- If found print train details
- Close the file
- Stop
Example:
We have to enter certain values here like train name, train no, starting place , ending place, date and time.
Input 1:
Vaigai Express , 020203 , Madurai , Chennai , 25/02/2021 , 09.15
Input 2:
Jan Shadabthi Express, 020204 , Coimbatore , Mayiladuthurai , 26/02/2021 , 03.45
Input 3:
Rockfort Express , 020205 , Trichy , Chennai , 27/02/2021 , 10.45
Input 4:
Tejas Express , 020206 , Madurai , Chennai , 28/02/2021 , 05.15
Now Do you want to continue (1/0)
1
Enter train No to be searched: 020204
Jan Shadabthi Express, 020204 , Coimbatore , Mayiladuthurai , 26/02/2021 , 03.45
Project Files
| .. | ||
| This directory is empty. | ||