Coders Packet

Random access in File Handling Using C++ Programming Language

By Srivenurajulu G

  • rdm.cpp
  • Random access in file handling.txt
  • Source code Random access in file handling.docx
  • 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:

    1. Start
    2. Define class train
    3. Read and print the train details using get() and print()
    4. main()
    5. Open file in write mode
    6. If in==NULL. Print error in creating file otherwise goto 7
    7. Call get()
    8. Enter the data into the file
    9. If the user wishes to continue repeat steps 7 and 8
    10. Open the file in read mode
    11. Enter the train no to be searched
    12. Use seekg()
    13. If found print train details
    14. Close the file
    15. 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

     

    Download Complete Code

    Comments

    No comments yet