Railway Reservation System Project in C with Source Code

This Railway Reservation System in C Language is developed using C programming language. The aim of this system To develop a safe and efficient railway reservation and administration system, as well as a search system for trains and passenger information, to assign seats to passengers on the waiting list, and to construct a login system for securing passenger booking information.

By building a safe and speedier railway reservation and search system for trains and passenger details, this project intends to improve the railway administration system, which will be valuable for both authorities and passengers.

This project’s scope is much broader than an engineering endeavor. This might be implemented in a real-world railway management system to allow for faster data access and better waiting management. This strategy can also be used to other modes of transportation.

The program’s complexity must be considerably raised in order to retain the dates and times of travel. Each train must have a distinct instance of it for each day. The database will grow in size as a result, and the application will need to be updated to reflect the system calendar. This level of sophistication was not feasible for this project, so the trains were instead classified as everyday trains.

Anyway if you want level up your knowledge in programming especially C/C++ Programming Language, try this new article I’ve made for you Best C Projects with Source Code for Beginners Free Download 2020.

To run this Railway Reservation System in C make sure that you have a Code Blocks or any platform of C installed in your computer. Please scroll down and click the download button to obtain a free copy of the Railway Reservation System project.

ABOUT PROJECTPROJECT DETAILS
Project Name : Railway Reservation System
Project Platform :C/C++
Programming Language Used:C Programming Language
Developer Name :itsourcecode.com
IDE Tool (Recommended):Dev-C++/Codeblocks
Project Type :Desktop Application
Database:Stores data in .DAT file
Railway Reservation System in C with Source Code Overview

Railway Reservation System in C Steps On How To Run The Project

Time needed: 5 minutes.

Here’s the step’s on how to run a Railway Reservation System in C with Source Code.

  • Step 1: Extract file.

    Next, after you finished download the source code, extract the zip file.
    Extract File for Railway Reservation System in C with Source Code

  • Step 2: Open CodeBlocks

    After that, After extracting the zip file, open your “CodeBlocks IDE”.
    Open Code blocks Apps for Extract file for Matchstick game in C with Source Code

  • Step 3: Open Project.

    Then, open file tab and Open File after that open folder RRS-IN-C then click the “main“.

  • Step 4: Run Project

    Lastly, Open build tab and select build and run or you can use key F9.

  • Step 5: The actual code.

    Finally, You are free to copy the given source code below or download the downloadable source code given.

This Railway Reservation System in C was build and run under Code::Blocks IDE.

  • Function to create main menu in the system.
void mainmenu(char user[20],char pw[20]){
    char choice;
    check=0;
    retry:
    system("cls");
    printf("\n\t\t WELCOME, %s.\n",user);
   
    printf("\n\t\t|\t CHOOSE WHAT TO DO\t\t\t |");
    printf("\n\t\t|\t _______________________________\t |");
   
    printf("\n\t\t|\t| 1. Book new tickets\t\t|\t |");
    printf("\n\t\t|\t| 2. Cancel booked trips\t|\t |");
    printf("\n\t\t|\t| 3. Check upcoming travels\t|\t |");
    printf("\n\t\t|\t| 4. Check waitlist\t\t|\t |");
    printf("\n\t\t|\t| 5. Logout\t\t        |\t |");
  • Function to create a sign up.
void signup(){
    char user[20],pw[20],c;
    char dir[100]="./railway dbs/";
    int len,ch,i;
    FILE *fptr;
    redouser:
    strcpy(dir,"./railway dbs/");
    ch=0;
    system("cls");
    printf("\n\t\t __________________________");
    printf("\n\t\t|\t\t\t   |");
    printf("\n\t\t|\t SIGN UP\t   |");
    printf("\n\t\t|__________________________|");
    printf("\n\n\t\tNOTE : Username should consist of 6-16 characters\n\t\t [Only numbers and alphabets without space]");
    printf("\n\n\t\tUSERNAME : ");
    scanf("\n");
    scanf("%[^\n]%*c",user);
    len=strlen(user);
    if(len>16 || len<6)
    {
        printf("\n\t\tWARNING : Username does not follow conditions. Retry.");
  • The function to start up main window
void startup(){
    char choice;
    system("cls");
    system("color 1F");
   
    printf("\n\t\t\t   WELCOME TO MANILA TRAIN RAILWAY SERVICE\n\n");
    
    printf("\n\n\t\tPress any to continue...... "); getch();
    redo:
    system("cls");
   
    printf("\n\t\t\t CHOOSE YOUR OPTION\t\t\t ");
   
   
    printf("\n\t\t\t 1. Login to Existing Account\t\t");
    printf("\n\t\t\t 2. Create New Account\t\t");
    printf("\n\t\t\t3. Exit\t\t ");
   
    choice=getch();
    if(choice!='1'&&choice!='2'&&choice!='3')
    {
        printf("\n\t\tWarning : INVALID INPUT. TRY AGAIN\n");
        delay(1);
        goto redo;
    }
    else
    {
        if(choice=='1')
            login();
        else if(choice=='2')
            signup();
        else if(choice=='3')
            shutdown();
    }
}
  • Function to search new booking
int* search(char user[20],char pw[20],int c){
    int choice,origin,dest,n_trains,i,*lst,*index=malloc(3*sizeof(int));
    char option,ch;
    if(c==0){
        redo_origin :
        system("cls");
        
        printf("\n\t\t\t NEW BOOKING\t");
        
        printf("\n\n\t\t NOTE : Choose Where you wish to travel from.\n");
        display_stations();
        printf("\n\t\t CHOICE : ");
        scanf("%d",&choice);
        if(choice<=0 || choice>34){
            printf("\n\t\t WARNING : INVALID OPTION. RETRY.");
            delay(1);
            goto redo_origin;
        }
  • Function to check up coming travels.
void check_upcoming(char user[20],char pw[20]){
    FILE *in;
    char dir[100]="./railway dbs/",ps[20];
    struct passenger p;
    int i=0;
    strcat(dir,user);strcat(dir,".txt");
    in = fopen(dir,"r");
    system("cls");
   
    printf("\n\t\t|   UPCOMING TRAVELS\t   |");
    
    fscanf(in,"%s ",&ps);
  • The function to check waiting list.
void check_waitlist(char user[20],char pw[20]){
    FILE *in;
    char dir[100]="./railway dbs/",ps[20];
    struct passenger p;
    int i=0;
    strcat(dir,user);strcat(dir,".txt");
    in = fopen(dir,"r");
    system("cls");
    
    printf("\n\t\t|\tWAITING LIST\t   |");
    
    fscanf(in,"%s ",&ps);
  • Function to cancel booking.
void cancelbooking(char user[20],char pw[20]){
    FILE *in,*out;
    char dir[100]="./railway dbs/",ps[20],c,dir2[100];
    struct passenger p,r;
    struct waitlist *t,*s;
    int i=0,n,index;
    strcat(dir,user);strcat(dir,".txt");
    redoview:
    i=0;
    in = fopen(dir,"r");
    system("cls");
    
    printf("\n\t\t|\tCANCEL BOOKING\t   |");
    
    fscanf(in,"%s",&ps);

Downloadable Source Code

Conclusion

This Railway Reservation System Project in C with Source Code is only a project made for school requirement purposes only. A Railway Reservation System in C language was created specifically for a semester project.

It aims to give beginners a good understanding of programming small to large projects by imparting general workable and practical information about C. You can download this program and modify it to suit your client requirements, since this is a student project it means you cannot really expect 100% functionality from this.

Inquiries

If you have any questions or suggestions about Railway Reservation System in C Source Code, please feel free to leave a comment below.

2 thoughts on “Railway Reservation System Project in C with Source Code”

Leave a Comment