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.

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;
    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;
    strcpy(dir,"./railway dbs/");
    printf("\n\t\t __________________________");
    printf("\n\t\t|\t\t\t   |");
    printf("\n\t\t|\t SIGN UP\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 : ");
    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("color 1F");
    printf("\n\t\t\t   WELCOME TO MANILA TRAIN RAILWAY SERVICE\n\n");
    printf("\n\n\t\tPress any to continue...... "); getch();
    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 ");
        printf("\n\t\tWarning : INVALID INPUT. TRY AGAIN\n");
        goto redo;
        else if(choice=='2')
        else if(choice=='3')
  • 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;
        redo_origin :
        printf("\n\t\t\t NEW BOOKING\t");
        printf("\n\n\t\t NOTE : Choose Where you wish to travel from.\n");
        printf("\n\t\t CHOICE : ");
        if(choice<=0 || choice>34){
            printf("\n\t\t WARNING : INVALID OPTION. RETRY.");
            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;
    in = fopen(dir,"r");
    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;
    in = fopen(dir,"r");
    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;
    in = fopen(dir,"r");
    printf("\n\t\t|\tCANCEL BOOKING\t   |");

Downloadable Source Code


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.


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

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

Leave a Comment