This project is a simple election management system designed for use in a school or college environment. It allows students to vote for candidates and provides administrators with tools to manage the election process.
- Student Panel: Allows students to cast their votes for candidates.
- Admin Panel: Enables administrators to:
- Start a new election.
- Continue a previous election.
- Delete illegal votes.
- Ban specific user IDs.
- View election results.
The project consists of three main files:
- main.c: The entry point of the program.
- election.h: The header file containing structure definitions, global variables, and function prototypes.
- election.c: The implementation of all functions declared in
election.h.
-
Compile the Program:
gcc main.c election.c -o election
-
Run the Program:
./election
-
Follow the Menu:
- Student Panel: Enter user ID and cast your vote.
- Admin Panel: Authenticate as admin and manage the election.
- main(): Displays the main menu and directs to the student or admin panel based on user input.
- extractYear(char userID[15]): Extracts the year from the user ID.
- extractRollNo(char userID[15]): Extracts the roll number from the user ID.
- checkBranchCode(char userID[15]): Checks if the branch code in the user ID matches the current valid branch.
- authenticateAdmin(): Authenticates the admin using a username and password.
- banID(): Bans user IDs and stores them in
Banned.txt. - createCandidateFiles(): Creates files for each candidate to store their votes and names.
- deleteIllegalVote(char userID[15]): Deletes an illegal vote.
- getWinner(): Determines the winner of the election.
- initiateNewElection(): Initiates a new election.
- saveElectionInfoInFile(): Saves the current election information to
ElectionInfo.txt. - loadElectionInfoFromFile(): Loads election information from
ElectionInfo.txt.
- isValid(char userID[15]): Checks if a user ID is valid for the current election.
- isVoted(char userID[15]): Checks if a user ID has already voted.
- isBanned(char userID[15]): Checks if a user ID is banned.
- saveVote(char userID[15], char voteInput): Saves a vote to the appropriate candidate's file.
- adminPanel(): Handles admin actions such as starting a new election, continuing a previous election, deleting illegal votes, banning user IDs, and viewing results.
- studentPanel(): Handles the student voting process, including checking user ID validity, displaying candidates, and saving votes.
- main.c: Contains the main function and the program loop.
- election.h: Header file with structure definitions, global variables, and function prototypes.
- election.c: Implementation of all the functions declared in
election.h. - ElectionInfo.txt: Stores the current election information.
- Banned.txt: Stores the banned user IDs.
- candidateX.txt: Stores the vote count and name for each candidate, where X is the candidate ID.
- Ensure that
ElectionInfo.txtandBanned.txtare present in the working directory when running the program to avoid errors. - The admin username is
Adminand the password isadmiN.
This project is open-source and free to use under the MIT License.