Employee Management System In C Programming

Employee Management System In C Programming Example

In today’s tutorial, we will create a simple Simple Employee Management System In C Programming Language. We’ll look at how to create an employee management system in C in this collection of C Projects Source Code. Using this employee management system, we may manage the data of employees who work for a company or organization. Here, the data is saved using the file handling technique, and the project’s name should give you an idea of what is being done.

This Simple Employee Management System’s main purpose is for the storage of employees’ information. The program is in the C programming language. It creates a broad understanding of how employee information, such as their name, address, contact numbers, etc. The user interface is relatively straightforward, with a standard screen design, so that staff may quickly become acquainted with it. A simple and easy-to-understand project based on the C programming language that involves the keeping of personal records for information gathering. Furthermore, this mini c programming project includes a minimal number of features. It is suitable for usage as a college project for first-year IT students studying C programming.

Background Study of Employee Management System In C Programming

Keeping records of workers details in traditional pen and paper is kind of worrisome for a user. Users have to search manually one by one in order to find the record. It consumes much time which is intimidating for a user. Moreover in the traditional way of keeping records. We use a lot of diary books involved and from time to time we need to keep buying a new one to keep records. Did you see the problem with the old method? Yes to overcome the barrier of more diary books and less time to find the record. So a new and modern application is the solution to this existing problem. Employee Management System In C Programming desktop application overcomes this barrier. It’s simple and easy to use by anyone using this software.

With this new and modern desktop application, you can simply do the above kinds of stuff with much more ease and in an elegant way. Easily add records and search them in no time, and edit them without any problem. With the help of this, desktop application users do not have to worry about any kind of memory-related issues, it is optimized and updated. This project is simple and easy to use.

About The Project

For the purposes of this project, this system provides a wide range of features. This project teaches students how to create a data storage system Employee Management System In C programming language. The project used field validation to guarantee that proper data was entered into each field. Talking more about the depth of this project, it offers you incredible services. Services like login, creating an account, deposit, and much more. This project will enhance the student’s ability to make projects on larger terms.

Some Important Terms

  • #include <stdio.h>: This is the first thing you will need to put in your file before you run the C project. It is one of the important header files that the C compiler will detect. This header file will us to use the print and scan statement in our program, i.e it stands for standard input-output. Make sure you include this header file above your code.

Building Employee Management System In C Programming

The only restriction on this project’s use of the Insert, Edit, and Delete file operations is that you can only view the data, not specifically search for any data item. Using the searching techniques, you can modify this program if you have more C programming knowledge. The source code is available for download under the button below the picture; you may use it to obtain a better understanding of the project.

The following modules are included in this project.

  • Add Employee Details
  • Edit Employee details
  • Modify Employee
  • Delete Employee
#include <stdio.h> ///for input output functions like printf, scanf
#include <stdlib.h>
#include <conio.h>
#include <windows.h> ///for windows related functions (not important)
#include <string.h>  ///string operations

/** List of Global Variable */
COORD coord = {0,0}; /// top-left corner of window

/**
    function : gotoxy
    @param input: x and y coordinates
    @param output: moves the cursor in specified position of console
*/
void gotoxy(int x,int y)
{
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}

/** Main function started */

int main()
{
    FILE *fp, *ft; /// file pointers
    char another, choice;

    /** structure that represent a employee */
    struct emp
    {
        char name[40]; ///name of employee
        int age; /// age of employee
        float bs; /// basic salary of employee
    };

    struct emp e; /// structure variable creation

    char empname[40]; /// string to store name of the employee

    long int recsize; /// size of each record of employee

    /** open the file in binary read and write mode
    * if the file EMP.DAT already exists then it open that file in read write mode
    * if the file doesn't exit it simply create a new copy
    */
    fp = fopen("EMP.DAT","rb+");
    if(fp == NULL)
    {
        fp = fopen("EMP.DAT","wb+");
        if(fp == NULL)
        {
            printf("Connot open file");
            exit(1);
        }
    }

    /// sizeo of each record i.e. size of structure variable e
    recsize = sizeof(e);

    /// infinite loop continues untile the break statement encounter
    while(1)
    {
        system("cls"); ///clear the console window
        gotoxy(30,10); /// move the cursor to postion 30, 10 from top-left corner
        printf("1. Add Record"); /// option for add record
        gotoxy(30,12);
        printf("2. List Records"); /// option for showing existing record
        gotoxy(30,14);
        printf("3. Modify Records"); /// option for editing record
        gotoxy(30,16);
        printf("4. Delete Records"); /// option for deleting record
        gotoxy(30,18);
        printf("5. Exit"); /// exit from the program
        gotoxy(30,20);
        printf("Your Choice: "); /// enter the choice 1, 2, 3, 4, 5
        fflush(stdin); /// flush the input buffer
        choice  = getche(); /// get the input from keyboard
        switch(choice)
        {
        case '1':  /// if user press 1
            system("cls");
            fseek(fp,0,SEEK_END); /// search the file and move cursor to end of the file
            /// here 0 indicates moving 0 distance from the end of the file

            another = 'y';
            while(another == 'y')  /// if user want to add another record
            {
                printf("\nEnter name: ");
                scanf("%s",e.name);
                printf("\nEnter age: ");
                scanf("%d", &e.age);
                printf("\nEnter basic salary: ");
                scanf("%f", &e.bs);

                fwrite(&e,recsize,1,fp); /// write the record in the file

                printf("\nAdd another record(y/n) ");
                fflush(stdin);
                another = getche();
            }
            break;
        case '2':
            system("cls");
            rewind(fp); ///this moves file cursor to start of the file
            while(fread(&e,recsize,1,fp)==1)  /// read the file and fetch the record one record per fetch
            {
                printf("\n%s %d %.2f",e.name,e.age,e.bs); /// print the name, age and basic salary
            }
            getch();
            break;

        case '3':  /// if user press 3 then do editing existing record
            system("cls");
            another = 'y';
            while(another == 'y')
            {
                printf("Enter the employee name to modify: ");
                scanf("%s", empname);
                rewind(fp);
                while(fread(&e,recsize,1,fp)==1)  /// fetch all record from file
                {
                    if(strcmp(e.name,empname) == 0)  ///if entered name matches with that in file
                    {
                        printf("\nEnter new name,age and bs: ");
                        scanf("%s%d%f",e.name,&e.age,&e.bs);
                        fseek(fp,-recsize,SEEK_CUR); /// move the cursor 1 step back from current position
                        fwrite(&e,recsize,1,fp); /// override the record
                        break;
                    }
                }
                printf("\nModify another record(y/n)");
                fflush(stdin);
                another = getche();
            }
            break;
        case '4':
            system("cls");
            another = 'y';
            while(another == 'y')
            {
                printf("\nEnter name of employee to delete: ");
                scanf("%s",empname);
                ft = fopen("Temp.dat","wb");  /// create a intermediate file for temporary storage
                rewind(fp); /// move record to starting of file
                while(fread(&e,recsize,1,fp) == 1)  /// read all records from file
                {
                    if(strcmp(e.name,empname) != 0)  /// if the entered record match
                    {
                        fwrite(&e,recsize,1,ft); /// move all records except the one that is to be deleted to temp file
                    }
                }
                fclose(fp);
                fclose(ft);
                remove("EMP.DAT"); /// remove the orginal file
                rename("Temp.dat","EMP.DAT"); /// rename the temp file to original file name
                fp = fopen("EMP.DAT", "rb+");
                printf("Delete another record(y/n)");
                fflush(stdin);
                another = getche();
            }
            break;
        case '5':
            fclose(fp);  /// close the file
            exit(0); /// exit from the program
        }
    }
    return 0;
}

How To Run Employee Management System In C Programming

All you need to have is a codeblocks for C/C++ integration. You can download one from the link given above the table. Download the editor and follow these simple steps.

  • The first step is to download the project and unzip it.
  • Then, extract the project and check for the files in it.
  • Once you are ok with the available files open the C file in the editor.
  • Then, hit run, and there you go your project is up and running.
  • There you go, your project is up and running.
  • If any error occurs then, leave a comment.

JavaScript is one of the most popular programming languages in the market. Its rise in the developer community is significant and outstanding. When you are working on a web application then JavaScript is most for you. Hey, just do not delimit the potential of the JavaScript Programming Language as a web-specific language. With the introduction of many new frameworks and libraries, JavaScript has got some firepower to its armory. Click here to learn more about the trending javascript frameworks you need to learn.

As a Software Engineer and Developer, you are in the everchanging and frequent updating industry. Meaning that you just cannot rely on one specific programming language to sustain your work activity. You may need to learn some new technical stacks out there to meet the industry's needs/demands. While there are many programming language options out there, you can choose JavaScript as one of them to learn. Why so? Because it is one of the most popular ones and is in demand in the technical industry. Not only this but it's quite easy to learn also, I guess 😂. Mostly it also pays well. Actually it has been seen that a JavaScript developer is highly paid than most of the other languages out there. So why not not learn that pays you more. Moreover JavaScript is everywhere.

In simple terms Pagination means you move from one page to another page either by clicking the Buttons or Links attached to it. The items can be as First Page, Next Page, Previous Page, and the Last Page buttons or links depending upon the site you visit. To know more Click Here.

HTML, CSS, AND JAVASCRIPT are the basic building block of the web. Many aspiring web developers start their web development journey with them. But as a beginner, you might get confused about which projects should you build. So click the link below to find out more about building HTML CSS JavaScript projects. Click Here.

Conclusion

In this series of C Projects source code articles, we build an employment management system (EMS). We are able to monitor the personnel data for a business or organization. You’ll be able to tell what this project is about as soon as you hear the name. Data is saved in a designated file using a file handling method. So for our today’s tutorial for C programming, this is it. We will continue to keep posting the C mini-series tutorials so that you can learn C programming Language as fast as you can.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.