├── Employee-Management-System-master ├── _config.yml ├── google74a88ff2eea874a9.html ├── readme.pdf ├── Employee Management System-github.o ├── sitemap.xml ├── README.md └── Employee Management System-github.c ├── Hangman-C ├── PlayHangman.exe ├── Screenshot.png ├── README.md └── PlayHangman.c ├── Phonebook-C ├── snaps │ ├── front.JPG │ └── main.JPG ├── ebraj.txt ├── README.md └── infobook.c ├── Hotel-Management-System-C ├── hotel.PNG ├── README.md └── HMSC.c ├── secure-notepad-c ├── Secure_Notepad.exe ├── HEADERFILES.h ├── PASSWORD_SECURITY.h ├── NOTEPAD.h ├── NOTEPAD_HELP.h ├── FUNCTION.h ├── NOTEPAD_ADDTEXT.h ├── NOTEPAD_DISPLAY.h ├── NOTEPAD_DEMO.h ├── LOGIN_USER.h ├── README.md ├── Secure_Notepad.c ├── ABOUT.h ├── NOTEPAD_ENTERTEXT.h └── REGISTER_USER.h ├── IP Address Finder ├── Final_Document.pdf ├── README.md └── Splay Tree.c ├── Cafeteria-System-C ├── menu.txt ├── README.md └── cafeteria_management.c ├── Bus-Reservation-in-C ├── Bus Reserevation Final C_Language │ ├── Bus_Reservation_System.exe │ └── Bus_Reservation_System.c ├── READ ME FIRST !!!!.txt └── README.md ├── Mini-Voting-System-master ├── MAIN.C ├── README.md └── ELECTION.H ├── Library-Management-System-main ├── README.md └── main.c ├── Tic Tac Toe Game ├── README.md └── Tic Tac Toe Game.cpp ├── Calculator-Master-C └── Calculator.c ├── Bank Account System ├── Readme.txt └── Main.c └── Rock Paper Scissor └── Rock Paper Scissor.c /Employee-Management-System-master/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /Employee-Management-System-master/google74a88ff2eea874a9.html: -------------------------------------------------------------------------------- 1 | google-site-verification: google74a88ff2eea874a9.html 2 | -------------------------------------------------------------------------------- /Hangman-C/PlayHangman.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/engineers-planet/C_Project_Free_Downloads/HEAD/Hangman-C/PlayHangman.exe -------------------------------------------------------------------------------- /Hangman-C/Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/engineers-planet/C_Project_Free_Downloads/HEAD/Hangman-C/Screenshot.png -------------------------------------------------------------------------------- /Phonebook-C/snaps/front.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/engineers-planet/C_Project_Free_Downloads/HEAD/Phonebook-C/snaps/front.JPG -------------------------------------------------------------------------------- /Phonebook-C/snaps/main.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/engineers-planet/C_Project_Free_Downloads/HEAD/Phonebook-C/snaps/main.JPG -------------------------------------------------------------------------------- /Hotel-Management-System-C/hotel.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/engineers-planet/C_Project_Free_Downloads/HEAD/Hotel-Management-System-C/hotel.PNG -------------------------------------------------------------------------------- /secure-notepad-c/Secure_Notepad.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/engineers-planet/C_Project_Free_Downloads/HEAD/secure-notepad-c/Secure_Notepad.exe -------------------------------------------------------------------------------- /IP Address Finder/Final_Document.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/engineers-planet/C_Project_Free_Downloads/HEAD/IP Address Finder/Final_Document.pdf -------------------------------------------------------------------------------- /Employee-Management-System-master/readme.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/engineers-planet/C_Project_Free_Downloads/HEAD/Employee-Management-System-master/readme.pdf -------------------------------------------------------------------------------- /Phonebook-C/ebraj.txt: -------------------------------------------------------------------------------- 1 | Ebraj Chauthe Male gurungebraj22@gmail.com 9805813974 2 | Anizh Syangja Male problemslution222@gmail.com 9846093920 3 | Ebraj Chauthe Male gurungebraj22@gmail.com 13974 4 | -------------------------------------------------------------------------------- /Cafeteria-System-C/menu.txt: -------------------------------------------------------------------------------- 1 | pizza 16.00 30 2 | french 16.00 30 3 | sandwiches 10.00 30 4 | pasta 12.00 20 5 | salad 8.50 15 6 | burgers 14.00 25 7 | sushi 20.00 10 8 | tacos 11.50 15 9 | ice cream 5.00 50 10 | -------------------------------------------------------------------------------- /Employee-Management-System-master/Employee Management System-github.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/engineers-planet/C_Project_Free_Downloads/HEAD/Employee-Management-System-master/Employee Management System-github.o -------------------------------------------------------------------------------- /Bus-Reservation-in-C/Bus Reserevation Final C_Language/Bus_Reservation_System.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/engineers-planet/C_Project_Free_Downloads/HEAD/Bus-Reservation-in-C/Bus Reserevation Final C_Language/Bus_Reservation_System.exe -------------------------------------------------------------------------------- /Hotel-Management-System-C/README.md: -------------------------------------------------------------------------------- 1 | # Hotel-Management-System 2 | Password Protected Hotel Management System in C language. 3 | 4 | # 5 | 6 | ![](./hotel.PNG) 7 | 8 | # LOGIN DETAILS: 9 | 10 | Username: user 11 | 12 | Password: pass 13 | -------------------------------------------------------------------------------- /Phonebook-C/README.md: -------------------------------------------------------------------------------- 1 | ## And yeah, it requires the password, Password : ebrajdon 2 | Phonebook is a simple project built in C where you can save the Infos of a person and can modify and delete it too. 3 | 4 | ## Some Snaps 5 | ### 01. Password Page 6 | ![Front](/snaps/front.JPG) 7 | 8 | ### 02. Main Page 9 | ![Main](/snaps/main.JPG) 10 | -------------------------------------------------------------------------------- /Hangman-C/README.md: -------------------------------------------------------------------------------- 1 | # Hangman Game in C Programming (Dynamic Programming) 2 | Hangman Game in C Programming (Dynamic Programming) is developed by Aashish Maharjan inspired from an online creator. It is text based word guessing game. 3 | 4 | * Developer's Name: Aashish Maharjan 5 | * Version: 0.2.0 6 | * First Updated: 5th May, 2019 7 | * Second Updated: 27th Feb, 2024 8 | * Third Updated: 15th Mar, 2024 9 | * Available on Github 10 | 11 | [Visit Linkedin](https://www.linkedin.com/in/aacismaharjan/) 12 | 13 | ![Hangman Screenshot](./Screenshot.png) -------------------------------------------------------------------------------- /Bus-Reservation-in-C/READ ME FIRST !!!!.txt: -------------------------------------------------------------------------------- 1 | 2 | USERNAME & PASSWORD FOR THE PROGRAM :- 3 | 4 | Username : user 5 | Password : pass 6 | 7 | AND IF YOU WISH TO CHANGE YOUR PASSWORD: 8 | THEN, OPEN SOURCE FILE AND SCROLL DOWN. SEARCH FOR :- void login() 9 | CHANGE password AND DONT FORGET TO SAVE & COMPILE IT AFTER EDITING. 10 | 11 | DON'T DELETE THE (.txt) FILES INSIDE THE MAIN PROJECT FOLDER 12 | BECAUSE IT's THE DATABASE OF THIS PROJECT 13 | 14 | ***** IF YOU FIND ANY ERRORS OR ANY PROBLEMS RELATED THIS PROGRAM, FEEL FREE TO CONTACT US ***** 15 | 16 | ***** LEAVE A COMMENT IF YOU LOVED OUR WORK ***** 17 | 18 | 19 | -------------------------------------------------------------------------------- /Employee-Management-System-master/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | https://sohanuzzamansoad.github.io/Employee-Management-System-by-Sohanuzzaman-Soad/ 11 | 2019-03-12T10:05:07+00:00 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Mini-Voting-System-master/MAIN.C: -------------------------------------------------------------------------------- 1 | #include"election.h" 2 | 3 | int main(){ 4 | while(1){ 5 | printf("\n\t\t\t 1.Student panel \n\t\t\t 2.Admin panel \n\t\t\t 3.Exit \n\t\t\t Option:"); 6 | char input; 7 | scanf(" %c",&input); 8 | 9 | switch(input){ 10 | case '1': 11 | studentPanel(); 12 | break; 13 | case '2': 14 | adminPanel(); 15 | break; 16 | case '3': 17 | return 0; 18 | default: 19 | printf("\nInvalid option"); 20 | getch(); 21 | } 22 | } 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /Mini-Voting-System-master/README.md: -------------------------------------------------------------------------------- 1 | # Mini-Voting-System-Using-C-Language 2 | 3 | -> Allows us to set up a flexible and trustworthy voting system 4 | -> Applicable for large as well as small group of people e.g. a batch, a class. 5 | -> Keeps a record of every voting process. 6 | 7 | # How to use? 8 | ### You can fork or download the repo, Once you have both the files "MAIN.C" and "ELECTION.H", You just need to compile and run MAIN.C 9 | #### ( It's too easy, isn't it? ☺) 10 | ##### For Admin Panel Use Username: "Admin" Password: "admiN" 11 | 12 | # Below is the video to see demo of project 13 | ## Link: https://drive.google.com/file/d/17yFA8VC9chpWav8kXXIYQR4B55sf4W9b/view?usp=sharing 14 | 15 | ### Feel free to raise issues if you find some errors or want to clear your doubts... 16 | 17 | #### #mini project #voting system #c project 18 | -------------------------------------------------------------------------------- /secure-notepad-c/HEADERFILES.h: -------------------------------------------------------------------------------- 1 | /// h e a d e r f i l e s . H 2 | /// ______________________________________________________________ 3 | /// -------------------------------------------------------------- 4 | 5 | /// includes all required headerfiles of program 6 | 7 | /// ______________________________________________________________ 8 | /// -------------------------------------------------------------- 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "LOGIN_USER.h" 17 | #include "REGISTER_USER.h" 18 | #include "PASSWORD_SECURITY.h" 19 | #include "FUNCTION.h" 20 | #include "NOTEPAD.h" 21 | #include "NOTEPAD_HELP.h" 22 | #include "NOTEPAD_DEMO.h" 23 | #include "NOTEPAD_ENTERTEXT.h" 24 | #include "NOTEPAD_DISPLAY.h" 25 | #include "NOTEPAD_ADDTEXT.h" 26 | 27 | /// __________________________________________________________________ 28 | /// ------------------------------------------------------------------ 29 | -------------------------------------------------------------------------------- /IP Address Finder/README.md: -------------------------------------------------------------------------------- 1 | # IP-Address-Finder 2 | With the help of splay tree data structure, we would create a tree whose nodes are 3 | embedded with the Ip address of the device that are connect to a specific network router. In our 4 | code we have taken 11 devices connected to one network router and so there would be some 5 | common part in the Ip address of each of the devices. Now, router gets some specific data 6 | packets from the net which is supposed to be given to a specified device and so it uses searching 7 | operation to find the correct Ip address. To increase the speed of this process we use splay tress 8 | for searching and inserting the Ip addresses. It is the fastest data structure for searching 9 | operation. Therefore, the router sends the data packet to the specified Ip address when multiple 10 | devices are connected. Here we have used the random function to input the data packets so that 11 | there is no input function required and the processes is completely automatic as it takes place in 12 | network router. 13 | -------------------------------------------------------------------------------- /Library-Management-System-main/README.md: -------------------------------------------------------------------------------- 1 | # Library-Management-System 2 | Library Management System is specially designed for purpose of adding book’s records in a library. The system elaborates the basic concept for storing and generating the book’s detail.Here in this system, staff can sign up as a system admin. He/she can have full access to the system for maintaining daily records. The whole project is designed in ‘C’ language, different variables and strings have been used for the development of this project. It’s easy to operate and understand by users. This is a simple mini project in C, built as a console application without using graphics features. It’s just a demonstration of the use of file handling in C language.This project is totally complete and it error-free. 3 | 4 | # Features : 5 | 6 | - Log-In System. 7 | - Password Protected. 8 | - Functions such as Add books, Search books, Issue books, delete the record of books issued, view record of books issued are added here. 9 | 10 | 11 | # admin 12 | 13 | password: userpass 14 | -------------------------------------------------------------------------------- /Tic Tac Toe Game/README.md: -------------------------------------------------------------------------------- 1 | # Tic-Tac-Toe-Game-using-C 2 | The Simple Tic Tac Toe Game was developed in a simple windowed console application, that display the gameplay as a console log images. The players can play the game via keyboard bindings the numbers that display in the screen is the position where you place you bet.The first player to move is Player 1, you must place your bet to a position that you want to place. The first to form a (horizontal, vertical, diagonal) lines will win the game. So both players must think wisely and place your bet that will make you win the game. 3 | 4 | # Features: 5 | - Multiplayer Mode 6 | The project contains multiplayer mode feature that that can let two person to compete to each other. 7 | - User-friendly Interface 8 | This project was design with a simple user-friendly interface. 9 | - Basic Controls 10 | This project uses a basic control function so that player can easily be playable. 11 | 12 | 13 | # Install & Use 14 | - Go-to **Codeblocks** and Open **New Projects ** then select **Console Application** 15 | - After that select **c++** and Go to **source** then **main.c** 16 | - Put code on there 17 | - click on **Build** then **Run** 18 | - 19 | -------------------------------------------------------------------------------- /Employee-Management-System-master/README.md: -------------------------------------------------------------------------------- 1 | # EMS-C-Project 2 | Employee Management System in C Fully Based in Terminal a Simple but most relevant project of mine. 3 | 4 | 5 | 6 | 7 | ## INTRODUCTION: 8 | ### What is EMS? 9 | - Employee Management System is a distributed application, developed to maintain the details of employees working in any organization. 10 | - The EMS has been developed to override the problems prevailing in the practicing manual system. 11 | - It maintains the information about the personal and official details of the employees. 12 | 13 | 14 | 15 | 16 | ## OBJECTIVES OF OUR PROJECT: 17 | - This project aims to simplify the task of maintaining records of the employees of Company. 18 | - To develop an well-designed database to store employee information. 19 | - Provides full functional reports to management of Company. 20 | - The objective of this project is to provide a comprehensive approach towards the management of employee information. 21 | 22 | 23 | 24 | ## FEATURES : 25 | - Proper Login Screen (Invisible Password Typing). 26 | - Password Protected. 27 | - Encrypted File (Binary). 28 | - Easily Add, Delete, Modify Records. 29 | - Various Essential Queries. 30 | -------------------------------------------------------------------------------- /Calculator-Master-C/Calculator.c: -------------------------------------------------------------------------------- 1 | // C Program to make a Simple Calculator 2 | // Using switch case 3 | #include 4 | #include 5 | 6 | // Driver code 7 | int main() 8 | { 9 | char ch; 10 | double a, b; 11 | while (1) { 12 | printf("Enter an operator (+, -, *, /), " 13 | "if want to exit press x: "); 14 | scanf(" %c", &ch); 15 | 16 | // to exit 17 | if (ch == 'x') 18 | exit(0); 19 | printf("Enter two first and second operand: "); 20 | scanf("%lf %lf", &a, &b); 21 | 22 | // Using switch case we will differentiate 23 | // operations based on different operator 24 | switch (ch) { 25 | 26 | // For Addition 27 | case '+': 28 | printf("%.1lf + %.1lf = %.1lf\n", a, b, a + b); 29 | break; 30 | 31 | // For Subtraction 32 | case '-': 33 | printf("%.1lf - %.1lf = %.1lf\n", a, b, a - b); 34 | break; 35 | 36 | // For Multiplication 37 | case '*': 38 | printf("%.1lf * %.1lf = %.1lf\n", a, b, a * b); 39 | break; 40 | 41 | // For Division 42 | case '/': 43 | printf("%.1lf / %.1lf = %.1lf\n", a, b, a / b); 44 | break; 45 | 46 | // If operator doesn't match any case constant 47 | default: 48 | printf( 49 | "Error! please write a valid operator\n"); 50 | } 51 | 52 | printf("\n"); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /secure-notepad-c/PASSWORD_SECURITY.h: -------------------------------------------------------------------------------- 1 | /// p a s s w o r d _ s e c u r i t y . H 2 | 3 | /// ------------------------------------------------------------------------ 4 | /// It basically checks weather password entered is strong or weak 5 | /// ------------------------------------------------------------------------- 6 | 7 | 8 | #define FUNCTION int passwordsecure(char pswd[]) 9 | #define DECLATION int a=0, A=0, num=0, spe=0; 10 | #define LOOP for(int i=0; i='a' && pswd[i]<='z') a=1; 13 | #define LARGE else if(pswd[i]>='A' && pswd[i]<='Z') A=1; 14 | #define NUMBER else if(pswd[i]>='0' && pswd[i]<='9') num=1; 15 | #define SEP_CHAR else if( (pswd[i]>='!' && pswd[i]<='/') || pswd[i]=='@' || pswd[i] == '_') spe=1; 16 | #define INVALID_CHAR else if( (pswd[i]>=':' && pswd[i]<='?') || (pswd[i]>='[' && pswd[i]<='`') || (pswd[i]>='{' && pswd[i]<='~') ) return 3; 17 | 18 | #define STRENGTH if(a==1 && A==1 && num==1 && spe==1) return 1; 19 | #define IN_LOOP { SMALL LARGE NUMBER SEP_CHAR INVALID_CHAR } 20 | #define RETURN return 2; 21 | 22 | 23 | FUNCTION 24 | { 25 | DECLATION 26 | LENGTH 27 | LOOP 28 | IN_LOOP 29 | STRENGTH 30 | RETURN 31 | } 32 | -------------------------------------------------------------------------------- /Bank Account System/Readme.txt: -------------------------------------------------------------------------------- 1 | This article focuses on how to create a bank account system using C language and File handling in C. 2 | 3 | Approach: 4 | Let’s discuss the approach in detail, covering all the functions and their explanation in detail- 5 | 6 | Create a Menu in the main function and create different functions for the Menu, which will be called using switch case statements. There are four different functions- 7 | account()- This function is used to create a new account. 8 | transfermoney()- This function is used to transfer money to the account 9 | checkbalance()- This function is used to check the balance in the account. 10 | login()- This function is used to login into the account. 11 | First, create an account of our user by calling the account() function after the creation of an account, store all the data into a file using file handling functions. 12 | Then the user is able to transfer the amount to other users, for that transfermoney() function is called, and for checking the current balance in the account call checkbalance() function. 13 | Concepts of file handling will be used to store the data of the users, and then read all data from that particular file, store structures in a file because they are easy to write and read. 14 | 15 | Implementation: 16 | Let’s look at the C implementation of each of the modules of the program and finally consolidate all the modules together and create a full working program. -------------------------------------------------------------------------------- /secure-notepad-c/NOTEPAD.h: -------------------------------------------------------------------------------- 1 | /// N o T e P a D . H 2 | 3 | /// """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 4 | 5 | /// It has main notepad functionalities and call functions from other notepad file 6 | /// notepadinput() : Presents opening window of NOTEPAD 7 | /// choice() : Presents different functionalities to perform 8 | 9 | /// """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 10 | 11 | #define F1 59 12 | #define F2 60 13 | #define F3 61 14 | #define F4 62 15 | #define F5 63 16 | #define ESC 27 17 | #define ENTER 13 18 | #define BKSP 8 19 | 20 | 21 | char uname[30]; 22 | 23 | 24 | 25 | void notepadinput(char name[]) /// MAIN NOTEPAD FUNCTION 26 | { 27 | system("cls"); 28 | strcpy(uname, name); 29 | gotoxy(14, 4); 30 | printf("---^---x--^x^--- WELCOME %s , TO SECRET WORLD OF TEXT ---^x^--x---^---", name); 31 | gotoxy(37, 6); printf("e x p l o r e . f r e e l y "); 32 | gotoxy(29,10); printf("-+-+-+-+- ENTER YOUR CHOICE -+-+-+-+-");gotoxy(20,12); 33 | 34 | for(int i=0; i<57; i++) { printf("-");delay(15); } 35 | gotoxy(34,14); printf(">>> PRESS F1 FOR HELP <<<"); 36 | gotoxy(34,16); printf(">>> PRESS F2 FOR DEMO <<<"); 37 | gotoxy(31,18); printf(">>> PRESS F3 TO DISPLAY TEXT <<<"); 38 | gotoxy(33,20); printf(">>> PRESS F4 TO ADD TEXT <<<\n\n"); 39 | gotoxy(29,22);printf(">>>> PRESS F5 TO OVERWRITE FILE <<<<\n\n"); 40 | gotoxy(34,24); printf(">>> PRESS ESC TO EXIT <<<"); gotoxy(20,26); 41 | 42 | for(int i=0; i<57; i++) { printf("-"); delay(10);} gotoxy(3, 30); 43 | while(1) 44 | { int n=getch(); 45 | switch(n) 46 | { 47 | case F1 : notehelp();break; 48 | case F2 : notedemo();break; 49 | case F3: notedisplay();break; 50 | case F4: noteadd(); break; 51 | case F5: notewrite(); break; 52 | case ESC: escape(); break; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /secure-notepad-c/NOTEPAD_HELP.h: -------------------------------------------------------------------------------- 1 | /// N O T E P A D _ H E L P . h 2 | 3 | /// ```````````````````````````````````````````````````````````````````````````` 4 | /// It tells all important instructions regarding the use of notepad 5 | 6 | /// ```````````````````````````````````````````````````````````````````````````` 7 | 8 | void notehelp() 9 | { 10 | gotoxy(25,10); printf(". . . . . .^. i n s t r u c t i o n s .^. . . . . . ."); 11 | gotoxy(33,12); 12 | for(int i=0; i<19; i++) 13 | { 14 | printf("/"); delay(10); 15 | printf("\\"); delay(10); 16 | } 17 | 18 | gotoxy(20,14); 19 | for(int i=0; i<63; i++) 20 | { printf("-"); delay(10); } 21 | 22 | gotoxy(32,16); printf("1. NOTES CAN BE SAVED WITH TIMESTAP "); 23 | gotoxy(28,18); printf("2. BACKSPACE HIT IS SPECIFIED WITH <- SYMBOL "); 24 | gotoxy(34,20); printf("3. ONLY UNIQUE USERS EXIST "); 25 | gotoxy(19,22); printf("4. OVERWRITE MODE DELETES PREXISTING FILE AND ADD NEW TEXT "); 26 | gotoxy(22,24); printf("5. TEXT EDITOR MODE CONTINUES TO WRITE AFTER LAST LEFT "); 27 | gotoxy(30,26); printf("6. TO END INSERTION MODE HIT ESC KEY "); 28 | gotoxy(24,28); printf("7. READ MODE SHOWS ALL TEXT USER LAST ENTERED IN FILE"); 29 | gotoxy(23,30); printf("8. DEMO MODE PROVIDES VISUAL DEMO OF HOW TEXT IS INSERTED"); 30 | gotoxy(30,32); printf("9. DEMO MODE DOESN'T SAVE TEXT TO FILE "); 31 | gotoxy(20,34); printf("10. IT DOESN'T SUPPORT KEYBORD SHORTCUTS ( CTRL+V, CTR+S) ETC "); 32 | gotoxy(21,36); printf("11. HIT ENTER IF LESS SPACE IS AVAILABLE TO MAINTAIN MARGIN "); 33 | gotoxy(20,38); 34 | for(int i=0; i<63; i++) 35 | { printf("-"); delay(10); } 36 | 37 | gotoxy(31,40); 38 | for(int i=0; i<19; i++) 39 | { 40 | printf("\\"); delay(10); 41 | printf("/"); delay(10); 42 | } 43 | gotoxy(34,42); printf(">>> PRESS ESC TO GO BACK <<<\n\n"); 44 | while(1) 45 | { 46 | int k=getch(); 47 | if(k==ESC) notepadinput(uname); 48 | else continue; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /secure-notepad-c/FUNCTION.h: -------------------------------------------------------------------------------- 1 | /// F U N C T I O N S . h 2 | 3 | /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 | 5 | /// It holds all frequently called functions like - 6 | /// gotoxy() : Sets co-ordinates in console according to parameters passed 7 | /// logprompt() : Presents initial opening window 8 | /// escape() : Ends program 9 | /// delay : Helps in presenting little animation' 10 | 11 | /// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 12 | 13 | 14 | 15 | void gotoxy(int x, int y) /// PERFORM GOTO X , Y CO-ORDINATE IN PROMPT 16 | { 17 | COORD c; 18 | c.X = x; 19 | c.Y = y; 20 | 21 | SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c); 22 | } 23 | 24 | 25 | 26 | void delay(ms) /// DELAY's OPERATION 27 | { 28 | clock_t timeDelay=ms+ clock(); 29 | while(timeDelay>clock()); 30 | } 31 | 32 | 33 | int logprompt() /// OPENING PROMPT FOR USER 34 | { 35 | int n; 36 | gotoxy(9,6); 37 | printf("---- xx ------- xx ------- S e C u R e . N o T e P a D ------- xx -------- xx ----"); 38 | gotoxy(18,10); 39 | for(int i=0; i<61; i++) 40 | { printf("=");} 41 | gotoxy(38,13); 42 | printf("** PRESS F1 TO LOGIN **"); 43 | gotoxy(36,15); 44 | printf("** PRESS F2 TO REGISTER **"); 45 | gotoxy(35,17); 46 | printf("** PRESS F3 TO SEE ABOUT **"); 47 | gotoxy(37,19); 48 | printf("** PRESS ESC TO EXIT **"); 49 | gotoxy(25,21); 50 | printf("---------------*-*-**-**-**-**-*-*-------------\n\n"); 51 | gotoxy(18,24); 52 | for(int i=0; i<61; i++) 53 | { printf("=");} printf("\n\n\n"); 54 | n=getch(); 55 | return n; 56 | } 57 | 58 | 59 | void escape() /// ESC HIT CODE 60 | { 61 | system("cls"); 62 | 63 | gotoxy(10,12); 64 | for(int i=0; i<85; i++) 65 | { printf("="); delay(10);} 66 | delay(50); 67 | gotoxy(30,16); delay(400); 68 | printf("!!!!!!!! -x-x-x-x- NoTePaD CloSeD -x-x-x-x- !!!!!!\n\n\n\n"); 69 | gotoxy(10,20); 70 | for(int i=0; i<85; i++) 71 | { printf("="); delay(20);} 72 | gotoxy(0,30); getch(); 73 | exit(1); 74 | } 75 | -------------------------------------------------------------------------------- /secure-notepad-c/NOTEPAD_ADDTEXT.h: -------------------------------------------------------------------------------- 1 | /// n o t e p a d _ a d d t e x t . H 2 | 3 | /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | /// It adds entered text after last data and gives option of adding timestamp 6 | 7 | /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | // ADD NEW TEXT TO FILE // 10 | void noteadd() 11 | { 12 | system("cls"); gotoxy(14,4); 13 | printf("---^---x--^x^--- WELCOME %s , TO SECRET WORLD OF TEXT ---^x^--x---^---", uname); 14 | gotoxy(37,6); printf("e x p l o r e . f r e e l y "); 15 | gotoxy(23,10); printf(". . . . . . . c r e a t e . w o r l d . . . . . . . ."); 16 | gotoxy(30,12); 17 | for(int i=0; i<19; i++) 18 | { 19 | printf("/"); delay(10); 20 | printf("\\"); delay(10); 21 | } 22 | char head[25]=">>>>> ENTER TEXT <<<<<", chr; int j= 19; 23 | gotoxy(4, 16); 24 | for(int i=0; i<36; i++) 25 | { printf("-"); delay(10);} int i=0; 26 | while(head[i]!='\0'){printf("%c",head[i]);i++;delay(10);} 27 | for(int i=0; i<36; i++) 28 | { printf("-"); delay(10);} 29 | gotoxy(27,46); printf("xx-xx press esc to exit insertion mode xx-xx"); 30 | gotoxy(4,18); int f= 19; 31 | fflush(stdin); 32 | char text[1800], c; 33 | getch(); 34 | for(i=0; c!= ESC; i++) 35 | { 36 | c= getch(); int j=c; 37 | if(j== BKSP ) { i-=2; printf("<-"); continue; } 38 | if(j== ENTER) { text[i]='\n'; gotoxy(4,f); f++; continue;} 39 | text[i]=c; printf("%c",c); 40 | } text[i-1]='\0'; f+=3; 41 | fflush(stdin); gotoxy(4,f); 42 | for(int i=0; i<95; i++) 43 | { printf("-"); delay(5);} 44 | gotoxy(25,f+2); printf("f---||--||- press F1 to add timstamp -||-||-||---"); 45 | gotoxy(28,f+4); printf("---||--||- press F2 to add text -||-||-||---"); 46 | gotoxy(29,f+6); printf("---||--||- press F3 to go back -||-||-||---"); 47 | gotoxy(30,f+8); printf("---||--||- press ESC to exit -||-||-||---"); 48 | fflush(stdin); gotoxy(4,f+10); 49 | for(int i=0; i<95; i++) 50 | { printf("-"); delay(5);} 51 | while(1) 52 | { 53 | int k= getch(); 54 | if(k==F1) { notewrite_timestamp(1, f+12, 2, text); break;} /// FUNCTION YET TO ADD 55 | else if(k==F2) { notewrite_timestamp(2, f+12, 2, text); break;} /// FUNCTION YET TO ADD 56 | else if(k==F3) { notepadinput(uname); break;} 57 | else if(k==ESC) { escape(); break;} 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Rock Paper Scissor/Rock Paper Scissor.c: -------------------------------------------------------------------------------- 1 | // C program for the above approach 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | // Function to implement the game 8 | int game(char you, char computer) 9 | { 10 | // If both the user and computer 11 | // has choose the same thing 12 | if (you == computer) 13 | return -1; 14 | 15 | // If user's choice is stone and 16 | // computer's choice is paper 17 | if (you == 's' && computer == 'p') 18 | return 0; 19 | 20 | // If user's choice is paper and 21 | // computer's choice is stone 22 | else if (you == 'p' && computer == 's') return 1; 23 | 24 | // If user's choice is stone and 25 | // computer's choice is scissor 26 | if (you == 's' && computer == 'z') 27 | return 1; 28 | 29 | // If user's choice is scissor and 30 | // computer's choice is stone 31 | else if (you == 'z' && computer == 's') 32 | return 0; 33 | 34 | // If user's choice is paper and 35 | // computer's choice is scissor 36 | if (you == 'p' && computer == 'z') 37 | return 0; 38 | 39 | // If user's choice is scissor and 40 | // computer's choice is paper 41 | else if (you == 'z' && computer == 'p') 42 | return 1; 43 | } 44 | 45 | // Driver Code 46 | int main() 47 | { 48 | // Stores the random number 49 | int n; 50 | 51 | char you, computer, result; 52 | 53 | // Chooses the random number 54 | // every time 55 | srand(time(NULL)); 56 | 57 | // Make the random number less 58 | // than 100, divided it by 100 59 | n = rand() % 100; 60 | 61 | // Using simple probability 100 is 62 | // roughly divided among stone, 63 | // paper, and scissor 64 | if (n < 33) 65 | 66 | // s is denoting Stone 67 | computer = 's'; 68 | 69 | else if (n > 33 && n < 66) 70 | 71 | // p is denoting Paper 72 | computer = 'p'; 73 | 74 | // z is denoting Scissor 75 | else 76 | computer = 'z'; 77 | 78 | printf("\n\n\n\n\t\t\t\tEnter s for STONE, p for PAPER and z for SCISSOR\n\t\t\t\t\t\t\t"); 79 | 80 | // input from the user 81 | scanf("%c", &you); 82 | 83 | // Function Call to play the game 84 | result = game(you, computer); 85 | 86 | if (result == -1) { 87 | printf("\n\n\t\t\t\tGame Draw!\n"); 88 | } 89 | else if (result == 1) { 90 | printf("\n\n\t\t\t\tWow! You have won the game!\n"); 91 | } 92 | else { 93 | printf("\n\n\t\t\t\tOh! You have lost the game!\n"); 94 | } 95 | printf("\t\t\t\tYOu choose : %c and Computer choose : %c\n",you, computer); 96 | 97 | return 0; 98 | } 99 | -------------------------------------------------------------------------------- /Bus-Reservation-in-C/README.md: -------------------------------------------------------------------------------- 1 | # Bus Ticket Reservation System (C) 2 | 3 | Welcome to the Bus Ticket Reservation System project! This project is developed using the C programming language and allows users to book and manage bus tickets. The system provides a user-friendly interface for ticket reservation and also includes an executable file for easy execution. 4 | 5 | ## Table of Contents 6 | 1. [Features](#features) 7 | 2. [Installation](#installation) 8 | 3. [Usage](#usage) 9 | 4. [Contributing](#contributing) 10 | 11 | 12 | ## Features 13 | - **Ticket Booking:** Users can book bus tickets by providing necessary details such as source, destination, date, and passenger information. 14 | - **Seat Availability:** The system displays the available seats for a particular bus, helping users make informed decisions. 15 | - **Ticket Cancellation:** Users can cancel their booked tickets, and the system will update the seat availability accordingly. 16 | - **Ticket Modification:** Users can modify their booked tickets by changing passenger details or the travel date, subject to availability. 17 | - **Ticket History:** The system maintains a record of all ticket bookings and cancellations, allowing users to view their booking history. 18 | 19 | ## Installation 20 | To run the Bus Ticket Reservation System, follow these steps: 21 | 1. Clone or download the project files from the GitHub repository: [Bus-Reservation-in-C](https://github.com/Venkateeshh/Bus-Reservation-in-C). 22 | 2. Compile the source code files using a C compiler (e.g., GCC). 23 | ``` 24 | gcc main.c -o bus_reservation 25 | ``` 26 | 3. Execute the generated executable file. 27 | ``` 28 | ./bus_reservation 29 | ``` 30 | 31 | ## Usage 32 | Upon running the Bus Ticket Reservation System, you will be presented with a menu-driven interface. Follow the on-screen instructions to perform various operations, such as ticket booking, cancellation, and modification. The system will display relevant information and prompts to guide you through the process. Enjoy booking your bus tickets hassle-free! 33 | 34 | ## Contributing 35 | Contributions to this project are always welcome. If you find any issues or have ideas for improvements, please open an issue on the [GitHub repository](https://github.com/Venkateeshh/Bus-Reservation-in-C/issues). You can also fork the repository, make changes, and submit a pull request. 36 | 37 | 38 | We hope you find the Bus Ticket Reservation System useful and efficient for managing bus bookings. If you have any further questions or need assistance, please don't hesitate to reach out. Happy traveling! 39 | -------------------------------------------------------------------------------- /Cafeteria-System-C/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Cafeteria Management System 3 | 4 | This is a simple Cafeteria Management System implemented in C. The system allows users to manage a menu of food items, place orders, and perform administrative tasks such as adding, editing, and deleting food items. The system also includes features to display order summaries, manage a stack of orders for each table, and process orders from a queue. 5 | 6 | ## Features 7 | 8 | 1. **Display Menu:** View the current menu of food items with details such as name, price, and quantity. 9 | 10 | 2. **Place Order:** Customers can place orders by specifying their name, the item they want to order, and the quantity. 11 | 12 | 3. **Display Order Queue:** View the current orders in the queue, including customer names, item names, quantities, and prices. 13 | 14 | 4. **Admin Login:** Authenticate as an admin to access additional features. 15 | 16 | 5. **Admin Features:** 17 | - **Add Food Item:** Add a new food item to the menu. 18 | - **Edit Food Item:** Modify the details of an existing food item. 19 | - **Delete Food Item:** Remove a food item from the menu. 20 | - **Place Order:** Admins can also place orders on behalf of customers. 21 | - **Display Order Summary:** View a summary of all placed orders, including total sales. 22 | - **Display Stack:** View the current stack of orders for each table. 23 | - **Display Order Queue:** View the current orders in the queue. 24 | - **Process One Order:** Process and dequeue one order from the queue. 25 | 26 | 6. **Save Menu to File:** The system saves the current menu to a file named "menu.txt" to persist data between sessions. 27 | 28 | 7. **File Operations:** 29 | - **Load Menu from File:** Load the menu from the "menu.txt" file at the start of the program. 30 | - **Save Menu to File:** Save the current menu to the "menu.txt" file. 31 | 32 | ## Usage 33 | 34 | 1. Clone the repository: 35 | 36 | ```bash 37 | git clone https://github.com/your-username/cafeteria-management-system.git 38 | ``` 39 | 40 | 2. Compile the program: 41 | 42 | ```bash 43 | gcc cafeteria_management_system.c -o cafeteria_management_system 44 | ``` 45 | 46 | 3. Run the executable: 47 | 48 | ```bash 49 | ./cafeteria_management_system 50 | ``` 51 | 52 | 4. Follow the on-screen instructions to interact with the Cafeteria Management System. 53 | 54 | ## Note 55 | 56 | - The system uses a simple text file ("menu.txt") to store the menu items. Make sure the file is present in the same directory as the executable. 57 | 58 | - Admin credentials are hardcoded as follows: 59 | - Username: admin 60 | - Password: 123 61 | 62 | - The system includes a basic authentication mechanism. Users need to enter the correct username and password to access admin features. 63 | 64 | ## Contributing 65 | 66 | Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or create a pull request. 67 | 68 | ## License 69 | 70 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. 71 | 72 | -------------------------------------------------------------------------------- /secure-notepad-c/NOTEPAD_DISPLAY.h: -------------------------------------------------------------------------------- 1 | /// n o t e p a d _ d i s p l a y . H 2 | 3 | /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | /// It prints all previous data user entered till now 5 | /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6 | 7 | 8 | /* DISPLAY ENTER HIT FUNCTIONALITIES */ 9 | void enterhit_display() 10 | { 11 | system("cls"); gotoxy(14,4); 12 | printf("---^---x--^x^--- WELCOME %s , TO SECRET WORLD OF TEXT ---^x^--x---^---", uname); 13 | gotoxy(37,6); printf("e x p l o r e . f r e e l y "); 14 | gotoxy(23,10); printf(". . . . . . . v i s u a l . w o r l d . . . . . . . ."); 15 | gotoxy(30,12); 16 | for(int i=0; i<19; i++) 17 | { 18 | printf("/"); delay(10); 19 | printf("\\"); delay(10); 20 | } 21 | FILE *userfile= fopen(uname, "rb"); 22 | char text[50]=">>>>> FILE TEXT <<<<<", chr; int j= 19; 23 | gotoxy(4, 16); 24 | for(int i=0; i<36; i++) 25 | { printf("-"); delay(10);} int i=0; 26 | while(text[i]!='\0'){printf("%c",text[i]);i++;delay(10);} 27 | for(int i=0; i<36; i++) 28 | { printf("-"); delay(10);} 29 | 30 | gotoxy(4,18); 31 | for(int i=0; !feof(userfile); i++) 32 | { 33 | chr=fgetc(userfile); 34 | if(chr=='\n'){gotoxy(4,j);j++; continue;} 35 | printf("%c",chr); 36 | } j+=5; 37 | gotoxy(4,j); 38 | for(int i=0; i<95; i++) 39 | { printf("-"); delay(5);} 40 | gotoxy(27,j+2); printf("---||--||- press F1 to add text -||-||-||---"); 41 | gotoxy(26,j+4);printf("---||--||- press F2 to overwrite -||-||-||---"); 42 | gotoxy(27,j+6); printf("---||--||- press F3 to go back -||-||-||---"); 43 | gotoxy(27,j+8); printf("---||--||- press ESC to EXIT -||-||-||---\n\n"); 44 | gotoxy(4,j+10); 45 | for(int i=0; i<95; i++) 46 | { printf("-"); delay(5);} 47 | fclose(userfile); 48 | while(1) 49 | { 50 | int k= getch(); 51 | if(k==F1) { noteadd(); break;} 52 | else if(k==F2){ notewrite(); break;} 53 | else if(k==F3) {notepadinput(uname); break;} 54 | else if(k==ESC) {escape(); break;} 55 | } 56 | } 57 | 58 | /* DISPLAY FILE TEXT */ 59 | void notedisplay() 60 | { system("cls"); gotoxy(14,4); 61 | printf("---^---x--^x^--- WELCOME %s , TO SECRET WORLD OF TEXT ---^x^--x---^---", uname); 62 | gotoxy(37,6); printf("e x p l o r e . f r e e l y "); 63 | gotoxy(23,10); printf(". . . . . . . v i s u a l . w o r l d . . . . . . . ."); 64 | gotoxy(26,13); 65 | for(int i=0; i<23; i++) 66 | { 67 | printf("/"); delay(10); 68 | printf("\\"); delay(10); 69 | } 70 | gotoxy(34,15); printf("PRESS ENTER TO DISPLAY TEXT"); 71 | gotoxy(30,17); printf(">>>>>> PRESS F1 TO GO BACK <<<<<"); gotoxy(23,19); 72 | for(int i=0; i<26; i++) 73 | { printf("\\"); delay(10); printf("/"); delay(10);} printf("\n\n"); 74 | while(1) 75 | { 76 | int k= getch(); if(k==ENTER) { enterhit_display(); break;} 77 | else if(k==F1){ notepadinput(uname); break;} 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Tic Tac Toe Game/Tic Tac Toe Game.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | char Board[3][3] = {{'1','2','3'},{'4','5','6'},{'7','8','9'}}; 8 | 9 | int choice; 10 | int row,column; 11 | char turn = 'X'; 12 | bool draw = false; 13 | 14 | 15 | 16 | void display_board(){ 17 | 18 | 19 | 20 | cout<<"PLAYER - 1 [X]\t PLAYER - 2 [O]\n\n"; 21 | cout<<"\t\t\t\t | | \n"; 22 | cout<<"\t\t\t\t "<> choice; 43 | 44 | 45 | 46 | switch(choice){ 47 | case 1: row=0; column=0; break; 48 | case 2: row=0; column=1; break; 49 | case 3: row=0; column=2; break; 50 | case 4: row=1; column=0; break; 51 | case 5: row=1; column=1; break; 52 | case 6: row=1; column=2; break; 53 | case 7: row=2; column=0; break; 54 | case 8: row=2; column=1; break; 55 | case 9: row=2; column=2; break; 56 | default: 57 | cout<<"Invalid Move"; 58 | } 59 | 60 | if(turn == 'X' && Board[row][column] != 'X' && Board[row][column] != 'O'){ 61 | 62 | Board[row][column] = 'X'; 63 | turn = 'O'; 64 | }else if(turn == 'O' && Board[row][column] != 'X' && Board[row][column] != 'O'){ 65 | 66 | Board[row][column] = 'O'; 67 | turn = 'X'; 68 | }else { 69 | 70 | cout<<"Box already filled!\n Please choose another!!\n\n"; 71 | player_turn(); 72 | } 73 | 74 | display_board(); 75 | } 76 | 77 | 78 | bool gameover(){ 79 | 80 | for(int i=0; i<3; i++) 81 | if(Board[i][0] == Board[i][1] && Board[i][0] == Board[i][2] || Board[0][i] == Board[1][i] && Board[0][i] == Board[2][i]) 82 | return false; 83 | 84 | 85 | 86 | if(Board[0][0] == Board[1][1] && Board[0][0] == Board[2][2] || Board[0][2] == Board[1][1] && Board[0][2] == Board[2][0]) 87 | return false; 88 | 89 | 90 | for(int i=0; i<3; i++) 91 | for(int j=0; j<3; j++) 92 | if(Board[i][j] != 'X' && Board[i][j] != 'O') 93 | return true; 94 | 95 | 96 | draw = true; 97 | return false; 98 | } 99 | 100 | 101 | 102 | int main() 103 | { 104 | cout<<"\t\t\t\t\tWELCOME\n"; 105 | cout<<"\t\t\tT I C K -- T A C -- T O E -- G A M E\t\t\t"; 106 | cout<<"\n\t\t\t\t2 PLAYER MODE\n\t\t\t"; 107 | display_board(); 108 | while(gameover()){ 109 | 110 | player_turn(); 111 | 112 | } 113 | //if someone wins then there must be a change of turn after update 114 | if(turn == 'O' && draw == false){ 115 | cout<<"\n\nCongratulations!Player with 'X' has won the game"; 116 | } 117 | else if(turn == 'X' && draw == false){ 118 | cout<<"\n\nCongratulations!Player with 'O' has won the game"; 119 | } 120 | else 121 | cout<<"\n\nGAME DRAW!!!\n\n"; 122 | } 123 | 124 | -------------------------------------------------------------------------------- /secure-notepad-c/NOTEPAD_DEMO.h: -------------------------------------------------------------------------------- 1 | /// n o t e p a d _ d e m o . H 2 | 3 | /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 4 | 5 | /// It provides a beautiful interface where user can see a demo how use notepad properly 6 | 7 | /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 8 | 9 | 10 | void enterhit_demo() /// d e m o _ e n t e r _ h i t _ c a l l 11 | { 12 | system("cls"); gotoxy(14,4); 13 | printf("---^---x--^x^--- WELCOME %s , TO SECRET WORLD OF TEXT ---^x^--x---^---", uname); 14 | gotoxy(34,6); printf("e x p l o r e . f r e e l y "); 15 | gotoxy(25,10); printf(". . . . . .^. d e m o . w o r l d .^. . . . . . ."); 16 | gotoxy(30,12); 17 | for(int i=0; i<19; i++) 18 | { 19 | printf("/"); delay(10); 20 | printf("\\"); delay(10); 21 | } 22 | gotoxy(27,46); printf("xx-xx press esc to exit insertion mode xx-xx"); 23 | gotoxy(4, 14); printf("ENTER TEXT: "); 24 | char c; int i; 25 | char str[1800]; int f= 15; 26 | for(i=0; c!= ESC; i++) 27 | { 28 | c= getch(); int j=c; 29 | if(j== BKSP ) { i-=2; printf("<-"); continue; } 30 | if(j==ENTER) { str[i]='\n'; gotoxy(4,f); f++; continue;} 31 | str[i]=c; printf("%c",c); 32 | } str[i-1]='\0'; 33 | gotoxy(10,f+3); 34 | for(int i=0; i<85; i++) 35 | { printf("="); delay(10);} 36 | f+=6; gotoxy(5,f); i=0; 37 | printf("TEXT ENTERED: "); 38 | gotoxy(18,f); 39 | while(str[i]!='\0') 40 | { 41 | if(str[i]=='\n'){ f++; gotoxy(4,f);} 42 | else printf("%c", str[i]); i++; 43 | } printf("\n"); 44 | gotoxy(10,f+3); 45 | for(int i=0; i<85; i++) 46 | { printf("="); delay(10);} 47 | gotoxy(30,f+6); 48 | for(int i=0; i<19; i++) 49 | { 50 | printf("/"); delay(10); 51 | printf("\\"); delay(10); 52 | } 53 | 54 | gotoxy(27,f+8); printf("---||--||- press F1 to go back -||-||-||---"); 55 | gotoxy(27,f+10); printf("||-||-||- press F2 to test again -||-||-||"); 56 | gotoxy(30,f+12); 57 | for(int i=0; i<19; i++) 58 | { 59 | printf("\\"); delay(10); 60 | printf("/"); delay(10); 61 | } printf("\n\n\n"); 62 | f=getch(); 63 | while(1) 64 | { 65 | if(f==F1) notepadinput(uname); 66 | else if(f==F2) enterhit_demo(); 67 | f=getch(); 68 | } 69 | } 70 | 71 | 72 | void notedemo() /// M A I N _ D E M O _ F U N C T I O N 73 | { 74 | system("cls"); gotoxy(14,4); 75 | printf("---^---x--^x^--- WELCOME %s , TO SECRET WORLD OF TEXT ---^x^--x---^---", uname); 76 | gotoxy(34,6); printf("e x p l o r e . f r e e l y "); 77 | gotoxy(24,10); printf(". . . . . . .^. d e m o . w o r l d .^. . . . . . . ."); 78 | gotoxy(26,15); 79 | for(int i=0; i<23; i++) 80 | { 81 | printf("/"); delay(10); 82 | printf("\\"); delay(10); 83 | } 84 | gotoxy(30,17); printf("PRESS ENTER TO START INSERTING TEXT"); 85 | gotoxy(30,19); printf(">>>>>> PRESS F1 TO GO BACK <<<<<"); 86 | gotoxy(30,21); printf("* PRESS ESC TO EXIT INSETION MODE *"); 87 | gotoxy(23,23); 88 | for(int i=0; i<26; i++) 89 | { 90 | printf("\\"); delay(10); 91 | printf("/"); delay(10); 92 | } 93 | printf("\n\n\n"); 94 | while(1) 95 | { 96 | int k= getch(); 97 | if(k==ENTER) { enterhit_demo(); break;} 98 | else if(k==F1){ notepadinput(uname); break;} 99 | else if(k==ESC) {escape(); break; } 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /secure-notepad-c/LOGIN_USER.h: -------------------------------------------------------------------------------- 1 | /// L O G I N _ U S E R 2 | /// ================================================================================ 3 | 4 | /// ALL LOGIN FUNCTIONALITIES ARE PRESENT IN THIS HEADERFILE 5 | /// login() : It is main function that calls other additional functions 6 | /// checkuser() : It checks weather enter credentials match or not 7 | /// register() : It is called when there exists no user record 8 | 9 | /// ================================================================================= 10 | #define F1 59 11 | #define F2 60 12 | 13 | struct{char name[20];char pswd[20];}use; 14 | 15 | 16 | FILE *fptr; 17 | 18 | /// WHEN NO USERFILE DATA IS FOUND THIS FUNCTION IS CALLED 19 | /// IT TELLS USER TO FIRST REGISTER THEM & THEN LOGIN 20 | void registe() 21 | { gotoxy(22,12); 22 | { printf("-"); delay(10);} 23 | gotoxy(27,14); printf("---x---xx--xx- NO USERFILE EXIT -xx--xx---x---"); 24 | gotoxy(38, 16); printf("-- REGISTER FIRST --"); 25 | gotoxy(32, 18); delay(800); 26 | printf("---- PRESS F2 FOR REGISTERATION ----\n"); 27 | while(1){int k=getch(); if(k==F2)userreg();} /// userreg() is defined in REGISTER_USER.h file 28 | } 29 | 30 | 31 | /// CHECKS WEATHER ENTERED CREDENTIALS ARE VALID OR NOT 32 | void checkuser(char uname[], char upass[]) 33 | { fptr = fopen("userrecord.bin", "rb"); /// opens file in read mode 34 | if(fptr==NULL) registe(); 35 | int chku, chkp, found=0; 36 | while(!feof(fptr)) 37 | { fread(&use, sizeof(use), 1,fptr); 38 | chku= check(uname, use.name); /// check() is defined in REGISTER_USER.h file 39 | chkp= check(upass, use.pswd); /// it basically takes parameter and tells weather string are equal or not 40 | 41 | if(chku==1 && chkp==1) 42 | { found=1; fclose(fptr); /// gotoxy() is defined in FUNCTIONS.h file 43 | for(int i=0; i<53; i++) 44 | gotoxy(22,12); 45 | for(int i=0; i<53; i++) 46 | { printf("-");delay( 10); } /// delay() is defined in FUNCTIONS.h file 47 | gotoxy(27,14); 48 | printf("---x---xx--xx- DETAILS MATCHED -xx--xx---x---"); 49 | gotoxy(29,16); delay(300); 50 | printf("---- PRESS ENTER TO OPEN NOTEPAD ----\n"); 51 | gotoxy(22,18); 52 | for(int i=0; i<53; i++) 53 | { 54 | printf("-"); 55 | delay(10); 56 | } printf("\n"); 57 | int k=getch(); 58 | while(1) 59 | { if(k==13) notepadinput(uname); k= getch();} /// notepadinput() is defined in NOTEPAD.h file 60 | } else continue; 61 | } 62 | 63 | if(found==0) /// When Details did'nt match 64 | { gotoxy(22,12); 65 | for(int i=0; i<53; i++) 66 | { printf("-");delay(10); } 67 | gotoxy(26,14); 68 | printf("---x---xx--xx- INVALID LOGIN -xx--xx---x---"); 69 | gotoxy(34, 16); delay(800); 70 | printf("---- PRESS F1 TO TRY AGAIN ----\n"); 71 | while(1){int k=getch(); if(k==F1) login();} 72 | } 73 | } 74 | 75 | 76 | 77 | void login() /// MAIN LOGIN FUNCTION /// 78 | { char uname[20], upass[20], c; 79 | int i; 80 | gotoxy(25, 26); 81 | for(int i=0; i<46; i++) 82 | { printf(">"); delay(15);} 83 | 84 | system("cls"); gotoxy(25, 6); 85 | printf("------------------ LOGIN PROMPT ----------------"); 86 | gotoxy(38,8); 87 | printf("ENTER USERNAME: "); scanf("%s", uname); 88 | gotoxy(36,10); printf("ENTER PASSWORD: "); 89 | for(i=0; c!=13; i++) 90 | { c=getch(); 91 | if(c==8) { i-=2; continue; } 92 | upass[i]=c; printf("*"); 93 | } upass[i-1]='\0'; 94 | gotoxy(30,10); checkuser(uname, upass); return; 95 | } 96 | -------------------------------------------------------------------------------- /secure-notepad-c/README.md: -------------------------------------------------------------------------------- 1 | # secure_notepad 2 | 3 | ======================== * === * === * S E C U R E . N O T E P A D * === * === * ========================== 4 | 5 | 6 | =================================================================================================================== 7 | 8 | ABOUT PROJECT : 9 | 10 | A BRIEF OVERVIEW OF "Secure Notepad" 11 | PROJECT IS DEVELOPED BY PRAVEEN NEGI, II year UG. 12 | 13 | This Project is fully coded in C Language, and uses most of the basic understanding concepts of C. 14 | It is implemented using concepts like: FILE HANDLING , FUNCTION , POINTERS , HEADER FILE , TIME , SYSTEM etc ... 15 | 16 | Secure Notepad provides a user-friendly interface which he/she can use to access their text from 17 | It has a password protected, and a USER can either Login or Register themselves accordingly 18 | LOGIN_USER.h have login functionalities and login() performs Login task 19 | REGISTER_USER.h have register functionalities and userreg() performs REGISTERATION task 20 | 21 | Interface is presented beautifully using gotoxy(), delay() functions. 22 | gotoxy() helps to set co-ordinate on console 23 | delay() is used in a manner such that it provides a little animation 24 | 25 | AFTER USER CREATES ACCOUNT OR LOGIN HE CAN ACCESS TO HIS PERSONAL TEXT SERVICE 26 | 27 | 28 | -------------------------------------------- 29 | 30 | 31 | Various functionalities are provide for NOTEPAD 32 | Has Different Modes - READ , OVERWRITE , ADD , DEMO 33 | 34 | READ MODE - It displays all the text USER entered previously on interface 35 | "NOTEPAD_DISPLAY.h" has all functionalities for READ MODE 36 | OVERWRITE - It deletes all the previous memory and starts storing everything again 37 | "NOTEPAD_WRITE.h" has all functionalities of OVERWRITE MODE 38 | ADD MODE - It add more data after previously stored data. 39 | "NOTEPAD_ADDTEXT.h" has all functionalities of ADD MODE 40 | DEMO MODE - It provides a user-friendly interface where a user can check how everything works. 41 | "NOTEPAD_DEMO.h" has all functionalities of DEMO MODE 42 | 43 | 44 | ---------------------------------------------------- 45 | 46 | 47 | NOTEPAD & INTERFACE PROVIDED ARE DIFFERENT IN BEHAVIOUR AND HAVE CERTAIN SET OF RULES TO USE 48 | 49 | 1. NOTES CAN BE SAVED WITH TIMESTAP 50 | 2. BACKSPACE HIT IS SPECIFIED WITH <- SYMBOL 51 | 3. ONLY UNIQUE USERS EXIST 4. OVERWRITE MODE DELETES PREXISTING FILE AND ADD NEW TEXT 52 | 5. TEXT EDITOR MODE CONTINUES TO WRITE AFTER LAST LEFT 53 | 6. TO END INSERTION MODE HIT ESC KEY 54 | 7. READ MODE SHOWS ALL TEXT USER LAST ENTERED IN FILE 55 | 8. DEMO MODE PROVIDES VISUAL DEMO OF HOW TEXT IS INSERTED 56 | 9. DEMO MODE DOESN'T SAVE TEXT TO FILE 57 | 10. IT DOESN'T SUPPORT KEYBORD SHORTCUTS ( CTRL+V, CTR+S) ETC 58 | 11. HIT ENTER IF LESS SPACE IS AVAILABLE TO MAINTAIN MARGIN 59 | 60 | THEY ARE PROVIDE IN "NOTEPAD_HELP.h" FILE 61 | 62 | ----------------------------------------- 63 | 64 | It also provides many other functionalities like 65 | i) securepassword() : IT CHECKS WEATHER PASSWORD ENTERED IS STRONG OR NOT 66 | ii) timestamp() : IT STORES THE TIMING WHEN DATA IS ENTERED 67 | iii) username_valid() : ALLOWS ONLY VALID USERNAME WITHOUT ANY SPECIAL CHAR OTHER THAN ' _ ' 68 | iv) userchk() : IT MAKES SURE THAT ONLY UNIQUE USERNAME EXISTS. IF USERNAME EXITS ALREADY IT DISALLOWS TO MAKE CHANGES AND ASK TO LOGIN 69 | v) inputuser() : Stores userdata credentials to a file 70 | 71 | ====================================================================================================================== 72 | 73 | 74 | You can easily use appliction ( Secure_Notepad.exe ) for windows. 75 | Or git clone whole repository and use commands 76 | 77 | gcc Secure_Notepad.c -o secure_notepad 78 | 79 | ./secure_notepad 80 | 81 | -------------------------------------------------------------------------------- /secure-notepad-c/Secure_Notepad.c: -------------------------------------------------------------------------------- 1 | /// * == * === * === * S E C U R E . N O T E P A D * === * == * 2 | 3 | #include "HEADERFILES.h" /// HEADERFILES.h includes all required headerfile for program 4 | #include "ABOUT.h" 5 | int main() 6 | { 7 | system("cls"); int n; 8 | system("color 70"); /// CAN USE TO CHANGE INTERFACE AND TEXT COLOUR 9 | 10 | while(1) 11 | { 12 | n= logprompt(); 13 | switch(n) 14 | { 15 | case F1 : login(); break; 16 | case F2 : userreg(); break; 17 | case F3 : about (); break; 18 | case ESC : escape(); 19 | } 20 | system("cls"); /// CLEARS SCREEN 21 | } 22 | } 23 | 24 | 25 | /// ======================== * === * === * S E C U R E . N O T E P A D * === * === * ========================== 26 | /* 27 | 28 | 29 | =================================================================================================================== 30 | 31 | ABOUT PROJECT : 32 | 33 | A BRIEF OVERVIEW OF "Secure Notepad" 34 | PROJECT IS DEVELOPED BY PRAVEEN NEGI, II year UG. 35 | 36 | This Project is fully coded in C Language, and uses most of the basic understanding concepts of C. 37 | It is implemented using concepts like: FILE HANDLING , FUNCTION , POINTERS , HEADER FILE , TIME , SYSTEM etc ... 38 | 39 | Secure Notepad provides a user-friendly interface which he/she can use to access their text from 40 | It has a password protected, and a USER can either Login or Register themselves accordingly 41 | LOGIN_USER.h have login functionalities and login() performs Login task 42 | REGISTER_USER.h have register functionalities and userreg() performs REGISTERATION task 43 | 44 | Interface is presented beautifully using gotoxy(), delay() functions. 45 | gotoxy() helps to set co-ordinate on console 46 | delay() is used in a manner such that it provides a little animation 47 | 48 | AFTER USER CREATES ACCOUNT OR LOGIN HE CAN ACCESS TO HIS PERSONAL TEXT SERVICE 49 | 50 | 51 | -------------------------------------------- 52 | 53 | 54 | Various functionalities are provide for NOTEPAD 55 | Has Different Modes - READ , OVERWRITE , ADD , DEMO 56 | 57 | READ MODE - It displays all the text USER entered previously on interface 58 | "NOTEPAD_DISPLAY.h" has all functionalities for READ MODE 59 | OVERWRITE - It deletes all the previous memory and starts storing everything again 60 | "NOTEPAD_WRITE.h" has all functionalities of OVERWRITE MODE 61 | ADD MODE - It add more data after previously stored data. 62 | "NOTEPAD_ADDTEXT.h" has all functionalities of ADD MODE 63 | DEMO MODE - It provides a user-friendly interface where a user can check how everything works. 64 | "NOTEPAD_DEMO.h" has all functionalities of DEMO MODE 65 | 66 | 67 | ---------------------------------------------------- 68 | 69 | 70 | NOTEPAD & INTERFACE PROVIDED ARE DIFFERENT IN BEHAVIOUR AND HAVE CERTAIN SET OF RULES TO USE 71 | 72 | 1. NOTES CAN BE SAVED WITH TIMESTAP 73 | 2. BACKSPACE HIT IS SPECIFIED WITH <- SYMBOL 74 | 3. ONLY UNIQUE USERS EXIST 4. OVERWRITE MODE DELETES PREXISTING FILE AND ADD NEW TEXT 75 | 5. TEXT EDITOR MODE CONTINUES TO WRITE AFTER LAST LEFT 76 | 6. TO END INSERTION MODE HIT ESC KEY 77 | 7. READ MODE SHOWS ALL TEXT USER LAST ENTERED IN FILE 78 | 8. DEMO MODE PROVIDES VISUAL DEMO OF HOW TEXT IS INSERTED 79 | 9. DEMO MODE DOESN'T SAVE TEXT TO FILE 80 | 10. IT DOESN'T SUPPORT KEYBORD SHORTCUTS ( CTRL+V, CTR+S) ETC 81 | 11. HIT ENTER IF LESS SPACE IS AVAILABLE TO MAINTAIN MARGIN 82 | 83 | THEY ARE PROVIDE IN "NOTEPAD_HELP.h" FILE 84 | 85 | ----------------------------------------- 86 | 87 | It also provides many other functionalities like 88 | i) securepassword() : IT CHECKS WEATHER PASSWORD ENTERED IS STRONG OR NOT 89 | ii) timestamp() : IT STORES THE TIMING WHEN DATA IS ENTERED 90 | iii) username_valid() : ALLOWS ONLY VALID USERNAME WITHOUT ANY SPECIAL CHAR OTHER THAN ' _ ' 91 | iv) userchk() : IT MAKES SURE THAT ONLY UNIQUE USERNAME EXISTS. IF USERNAME EXITS ALREADY IT DISALLOWS TO MAKE CHANGES AND ASK TO LOGIN 92 | v) inputuser() : Stores userdata credentials to a file 93 | 94 | ====================================================================================================================== 95 | */ 96 | 97 | -------------------------------------------------------------------------------- /secure-notepad-c/ABOUT.h: -------------------------------------------------------------------------------- 1 | /// a b o u t . H 2 | /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 | /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | 5 | void about() 6 | { 7 | system("cls"); 8 | printf("\n\n\n\n"); 9 | printf(" ================ * === * === * S E C U R E . N O T E P A D * === * === * ==================== \n\n\n"); 10 | printf(" ============================================================================================\n\n"); 11 | 12 | printf(" ABOUT PROJECT :\n\n"); 13 | 14 | printf(" A BRIEF OVERVIEW OF 'Secure Notepad'\n"); 15 | printf(" PROJECT IS DEVELOPED BY PRAVEEN NEGI, II year UG.\n\n"); 16 | 17 | printf(" This Project is fully coded in C Language, and uses most of the basic understanding concepts of C.\n"); 18 | printf(" It is implemented using concepts like: FILE HANDLING , FUNCTION, POINTERS, HEADER FILE, TIME etc ...\n\n"); 19 | 20 | printf(" Secure Notepad provides a user-friendly interface which he/she can use to access their text from\n"); 21 | printf(" It has a password protected, and a USER can either Login or Register themselves accordingly\n"); 22 | printf(" LOGIN_USER.h have login functionalities and login() performs Login task\n"); 23 | printf(" REGISTER_USER.h have register functionalities and userreg() performs REGISTERATION task\n\n"); 24 | 25 | printf(" Interface is presented beautifully using gotoxy(), delay() functions.\n"); 26 | printf(" gotoxy() helps to set co-ordinate on console\n"); 27 | printf(" delay() is used in a manner such that it provides a little animation\n\n"); 28 | 29 | printf(" AFTER USER CREATES ACCOUNT OR LOGIN HE CAN ACCESS TO HIS PERSONAL TEXT SERVICE\n\n\n"); 30 | 31 | 32 | printf(" --------------------------------------------\n\n\n"); 33 | 34 | 35 | printf(" OVERWRITE - It deletes all the previous memory and starts storing everything again\n"); 36 | printf(" 'NOTEPAD_WRITE.h' has all functionalities of OVERWRITE MODE\n"); 37 | printf(" ADD MODE - It add more data after previously stored data.\n"); 38 | printf(" 'NOTEPAD_ADDTEXT.h' has all functionalities of ADD MODE\n"); 39 | printf(" DEMO MODE - It provides a user-friendly interface where a user can check how everything works.\n"); 40 | printf(" 'NOTEPAD_DEMO.h' has all functionalities of DEMO MODE\n\n\n"); 41 | 42 | 43 | printf(" -------------------------------------------------------------\n\n\n\n"); 44 | 45 | 46 | 47 | printf(" NOTEPAD & INTERFACE PROVIDED ARE DIFFERENT IN BEHAVIOUR AND HAVE CERTAIN SET OF RULES TO USE\n\n"); 48 | 49 | printf(" 1. NOTES CAN BE SAVED WITH TIMESTAP\n"); 50 | printf(" 2. BACKSPACE HIT IS SPECIFIED WITH <- SYMBOL\n"); 51 | printf(" 3. ONLY UNIQUE USERS EXIST 4. OVERWRITE MODE DELETES PREXISTING FILE AND ADD NEW TEXT\n"); 52 | printf(" 5. TEXT EDITOR MODE CONTINUES TO WRITE AFTER LAST LEFT\n"); 53 | printf(" 6. TO END INSERTION MODE HIT ESC KEY\n"); 54 | printf(" 7. READ MODE SHOWS ALL TEXT USER LAST ENTERED IN FILE\n"); 55 | printf(" 8. DEMO MODE PROVIDES VISUAL DEMO OF HOW TEXT IS INSERTED\n"); 56 | printf(" 9. DEMO MODE DOESN'T SAVE TEXT TO FILE\n"); 57 | printf(" 10. IT DOESN'T SUPPORT KEYBORD SHORTCUTS ( CTRL+V, CTR+S) ETC\n"); 58 | printf(" 11. HIT ENTER IF LESS SPACE IS AVAILABLE TO MAINTAIN MARGIN\n\n"); 59 | 60 | printf(" THEY ARE PROVIDE IN 'NOTEPAD_HELP.h' FILE\n\n"); 61 | 62 | printf(" -------------------------------------------\n\n"); 63 | 64 | printf(" It also provides many other functionalities like\n"); 65 | printf(" i) securepassword() : IT CHECKS WEATHER PASSWORD ENTERED IS STRONG OR NOT\n"); 66 | printf(" ii) timestamp() : IT STORES THE TIMING WHEN DATA IS ENTERED\n"); 67 | printf(" iii) username_valid() : ALLOWS ONLY VALID USERNAME WITHOUT ANY SPECIAL CHAR OTHER THAN ' _ '\n"); 68 | printf(" iv) userchk() : IT MAKES SURE THAT ONLY UNIQUE USERNAME EXISTS. IF USERNAME EXITS ALREADY\n"); 69 | printf(" IT DISALLOWS TO MAKE CHANGES AND ASK TO LOGIN\n"); 70 | printf(" v) inputuser() : Stores userdata credentials to a file\n\n"); 71 | 72 | printf(" ================================================================================================= \n\n\n\n"); 73 | gotoxy(37,73); printf("** PRESS ESC TO GO BACK **\n\n\n"); 74 | printf(" ================================================================================================= \n\n\n\n"); 75 | while(1){int k=getch(); if(k==27)main();} 76 | } 77 | -------------------------------------------------------------------------------- /secure-notepad-c/NOTEPAD_ENTERTEXT.h: -------------------------------------------------------------------------------- 1 | /* NOTEPAD INPUT FUNCTIONALITIES */ 2 | 3 | /* INSERTS DATA IN FILE AND GIVE TIMESTAMP WITH CHOICE */ 4 | void notewrite_timestamp(int t, int f, int a, char text[]) 5 | { 6 | FILE *userfile; 7 | if(a==1) { userfile= fopen(uname, "wb"); } 8 | else if(a==2) { userfile= fopen(uname, "ab"); } 9 | if(t==1) 10 | { 11 | time_t t; time(&t); 12 | char *j= ctime(&t); 13 | char curr[200]="\n-+-+-+- TIME STAMP: "; 14 | strcat(curr,j); curr[45]=' '; 15 | strcat(curr, "-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-"); 16 | curr[93]='\n';curr[94]='\n'; 17 | fwrite(&curr, sizeof(char),95,userfile); 18 | } 19 | else{char j[2]="\n\n"; fwrite(&j, sizeof(char),2,userfile); } 20 | int len= strlen(text); 21 | gotoxy(30,f); 22 | for(int i=0; i<19; i++) 23 | { 24 | printf("/"); delay(10); 25 | printf("\\"); delay(10); 26 | } 27 | fwrite(&text, sizeof(char),len,userfile); 28 | if(t==1) 29 | { 30 | time_t t; time(&t); 31 | char *j= ctime(&t); 32 | char curr[200]="\n\n-^-^-^- TIME STAMP: "; 33 | strcat(curr,j); curr[46]=' '; 34 | strcat(curr,"-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-"); 35 | fwrite(&curr, sizeof(char),94,userfile); 36 | } 37 | gotoxy(36,f+2); printf("*** TEXT - INSERTED ***\n\n"); 38 | fclose(userfile); 39 | gotoxy(32,f+4); printf("*** PRESS ENTER TO GO BACK ***\n\n"); 40 | while(1){int k=getch(); if(k==13) notepadinput(uname);} 41 | } 42 | 43 | /* NOTEPAD OVERWRITE ENTER HIT FUNCTIONALITY */ 44 | void enterhit_write() 45 | { 46 | system("cls"); gotoxy(14,4); 47 | printf("---^---x--^x^--- WELCOME %s , TO SECRET WORLD OF TEXT ---^x^--x---^---", uname); 48 | gotoxy(37,6); printf("e x p l o r e . f r e e l y "); 49 | gotoxy(23,10); printf(". . . . . . . c r e a t e . w o r l d . . . . . . . ."); 50 | gotoxy(30,12); 51 | for(int i=0; i<19; i++) 52 | { 53 | printf("/"); delay(10); 54 | printf("\\"); delay(10); 55 | } 56 | char head[25]=">>>>> ENTER TEXT <<<<<", chr; int j= 19; 57 | gotoxy(4, 16); 58 | for(int i=0; i<36; i++) 59 | { printf("-"); delay(10);} int i=0; 60 | while(head[i]!='\0'){printf("%c",head[i]);i++;delay(10);} 61 | for(int i=0; i<36; i++) 62 | { printf("-"); delay(10);} 63 | gotoxy(27,46); printf("xx-xx press esc to exit insertion mode xx-xx"); 64 | gotoxy(4,18); int f= 19; fflush(stdin); 65 | char text[1800], c; 66 | for(i=0; c!= ESC; i++) 67 | { 68 | c= getch(); int j=c; 69 | if(j== BKSP ) { i-=2; printf("<-"); continue; } 70 | if(j== ENTER) { text[i]='\n'; gotoxy(4,f); f++; continue;} 71 | text[i]=c; printf("%c",c); 72 | } 73 | text[i-1]='\0'; f+=3; 74 | fflush(stdin); gotoxy(4,f); 75 | for(int i=0; i<95; i++) 76 | { printf("-"); delay(5);} 77 | gotoxy(25,f+2); printf("f---||--||- press F1 to add timstamp -||-||-||---"); 78 | gotoxy(28,f+4); printf("---||--||- press F2 to add text -||-||-||---"); 79 | gotoxy(29,f+6); printf("---||--||- press F3 to go back -||-||-||---"); 80 | gotoxy(30,f+8); printf("---||--||- press ESC to exit -||-||-||---"); 81 | fflush(stdin); 82 | gotoxy(4,f+10); 83 | for(int i=0; i<95; i++) 84 | { printf("-"); delay(5);} printf("\n\n"); 85 | while(1) 86 | { 87 | int k= getch(); 88 | if (k==F1) { notewrite_timestamp(1, f+12, 1, text); break;} /// FUNCTION YET TO ADD 89 | else if(k==F2) { notewrite_timestamp(2, f+12, 1, text); break;} /// FUNCTION YET TO ADD 90 | else if(k==F3) { notepadinput(uname); break;} 91 | else if(k==ESC) { escape(); break;} 92 | } 93 | } 94 | 95 | 96 | /* NOTEPAD OVERWRITE MAIN FUNCTION */ 97 | void notewrite() 98 | { 99 | system("cls"); gotoxy(14,4); 100 | printf("---^---x--^x^--- WELCOME %s , TO SECRET WORLD OF TEXT ---^x^--x---^---", uname); 101 | gotoxy(37,6); printf("e x p l o r e . f r e e l y "); 102 | gotoxy(23,10); printf(". . . . . . . c r e a t e . w o r l d . . . . . . . ."); 103 | gotoxy(26,13); 104 | for(int i=0; i<23; i++) 105 | { 106 | printf("/"); delay(10); 107 | printf("\\");delay(10); 108 | } 109 | gotoxy(34,15); printf("PRESS ENTER TO OVERWRITE TEXT"); 110 | gotoxy(30,17); printf(">>>>>> PRESS F1 TO GO BACK <<<<<"); 111 | gotoxy(28,19);printf(">>>>>> PRESS F2 TO ADD TEXt <<<<<"); 112 | gotoxy(23,21); 113 | for(int i=0; i<26; i++) 114 | { printf("\\"); delay(10); printf("/"); delay(10);} 115 | printf("\n\n"); 116 | while(1) 117 | { 118 | int k= getch(); 119 | if(k==ENTER) { enterhit_write(); break;} 120 | else if(k==F1){ notepadinput(uname); break;} 121 | else if(k==F2){ noteadd(); break; } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /IP Address Finder/Splay Tree.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | typedef struct node 4 | { 5 | int ipAdd; 6 | int dataPacket; 7 | struct node *left; 8 | struct node *right; 9 | struct node *parent; 10 | } node; 11 | 12 | typedef struct splay_tree 13 | { 14 | struct node *root; 15 | } splay_tree; 16 | 17 | node *new_node(int ipAdd) 18 | { 19 | node *n = malloc(sizeof(node)); 20 | n->ipAdd = ipAdd; 21 | n->parent = NULL; 22 | n->right = NULL; 23 | n->left = NULL; 24 | return n; 25 | } 26 | 27 | splay_tree *new_splay_tree() 28 | { 29 | splay_tree *t = malloc(sizeof(splay_tree)); 30 | t->root = NULL; 31 | return t; 32 | } 33 | 34 | node *maximum(splay_tree *t, node *x) 35 | { 36 | while (x->right != NULL) 37 | x = x->right; 38 | return x; 39 | } 40 | 41 | void left_rotate(splay_tree *t, node *x) 42 | { 43 | node *y = x->right; 44 | x->right = y->left; 45 | if (y->left != NULL) 46 | { 47 | y->left->parent = x; 48 | } 49 | y->parent = x->parent; 50 | if (x->parent == NULL) 51 | { 52 | t->root = y; 53 | } 54 | else if (x == x->parent->left) 55 | { 56 | x->parent->left = y; 57 | } 58 | else 59 | { 60 | x->parent->right = y; 61 | } 62 | y->left = x; 63 | x->parent = y; 64 | } 65 | 66 | void right_rotate(splay_tree *t, node *x) 67 | { 68 | node *y = x->left; 69 | x->left = y->right; 70 | if (y->right != NULL) 71 | { 72 | y->right->parent = x; 73 | } 74 | y->parent = x->parent; 75 | if (x->parent == NULL) 76 | { 77 | t->root = y; 78 | } 79 | else if (x == x->parent->right) 80 | { 81 | x->parent->right = y; 82 | } 83 | else 84 | { 85 | x->parent->left = y; 86 | } 87 | y->right = x; 88 | x->parent = y; 89 | } 90 | 91 | void splay(splay_tree *t, node *n) 92 | { 93 | while (n->parent != NULL) 94 | { 95 | if (n->parent == t->root) 96 | { 97 | if (n == n->parent->left) 98 | { 99 | right_rotate(t, n->parent); 100 | } 101 | else 102 | { 103 | left_rotate(t, n->parent); 104 | } 105 | } 106 | else 107 | { 108 | node *p = n->parent; 109 | node *g = p->parent; 110 | if (n->parent->left == n && p->parent->left == p) 111 | { 112 | right_rotate(t, g); 113 | right_rotate(t, p); 114 | } 115 | else if (n->parent->right == n && p->parent->right == p) 116 | { 117 | left_rotate(t, g); 118 | left_rotate(t, p); 119 | } 120 | else if (n->parent->right == n && p->parent->left == p) 121 | { 122 | left_rotate(t, p); 123 | right_rotate(t, g); 124 | } 125 | else if (n->parent->left == n && p->parent->right == p) 126 | { 127 | right_rotate(t, p); 128 | left_rotate(t, g); 129 | } 130 | } 131 | } 132 | } 133 | 134 | void insert(splay_tree *t, node *n) 135 | { 136 | node *y = NULL; 137 | node *temp = t->root; 138 | while (temp != NULL) 139 | { 140 | y = temp; 141 | if (n->ipAdd < temp->ipAdd) 142 | temp = temp->left; 143 | else 144 | temp = temp->right; 145 | } 146 | n->parent = y; 147 | if (y == NULL) 148 | t->root = n; 149 | else if (n->ipAdd < y->ipAdd) 150 | y->left = n; 151 | else 152 | y->right = n; 153 | splay(t, n); 154 | } 155 | 156 | node *search(splay_tree *t, node *n, int x) 157 | { 158 | if (x == n->ipAdd) 159 | { 160 | splay(t, n); 161 | return n; 162 | } 163 | else if (x < n->ipAdd) 164 | return search(t, n->left, x); 165 | else if (x > n->ipAdd) 166 | return search(t, n->right, x); 167 | else 168 | return NULL; 169 | } 170 | 171 | void inorder(splay_tree *t, node *n, char *cmn) 172 | { 173 | if (n != NULL) 174 | { 175 | inorder(t, n->left, cmn); 176 | printf("%s%d -> %d\n", cmn, n->ipAdd, 177 | n->dataPacket); 178 | inorder(t, n->right, cmn); 179 | } 180 | } 181 | 182 | int main() 183 | { 184 | char *cmn = "192.168.3."; 185 | splay_tree *t = new_splay_tree(); 186 | node *a, *b, *c, *d, *e, *f, *g, *h, *i, *j, *k, *l, *m; 187 | a = new_node(104); 188 | b = new_node(112); 189 | c = new_node(117); 190 | d = new_node(124); 191 | e = new_node(121); 192 | f = new_node(108); 193 | g = new_node(109); 194 | h = new_node(111); 195 | i = new_node(122); 196 | j = new_node(125); 197 | k = new_node(129); 198 | insert(t, a); 199 | insert(t, b); 200 | insert(t, c); 201 | insert(t, d); 202 | insert(t, e); 203 | insert(t, f); 204 | insert(t, g); 205 | insert(t, h); 206 | insert(t, i); 207 | insert(t, j); 208 | insert(t, k); 209 | int x; 210 | int find[11] = {104, 112, 117, 124, 121, 108, 109, 111, 211 | 122, 125, 129}; 212 | int add[11] = {a, b, c, d, e, f, g, h, i, j, k}; 213 | srand(time(0)); 214 | for (x = 0; x < 11; x++) 215 | { 216 | int data = rand() % 200; 217 | node *temp = search(t, add[x], find[x]); 218 | if (temp != NULL) 219 | { 220 | temp->dataPacket = data; 221 | } 222 | } 223 | printf("IP ADDRESS -> DATA PACKET\n"); 224 | inorder(t, t->root, cmn); 225 | return 0; 226 | } 227 | -------------------------------------------------------------------------------- /secure-notepad-c/REGISTER_USER.h: -------------------------------------------------------------------------------- 1 | /// R E G I S T E R _ U S E R . h 2 | /// ======================================================================== 3 | 4 | /// ALL REGISTERATION FUNCTIONALITIES ARE PRESENT IN THIS HEADERFILE 5 | /// userreg() : Main reg. function that calls other function 6 | /// username_valid() : Checks weather username entered is valid or not 7 | /// userchk() : Checks if username entered already exists 8 | /// inputuser() : Enters userdata to a file. 9 | /// check() : Checks weather parameters passed are equal or not 10 | 11 | /// ========================================================================= 12 | 13 | #define SPE_CHAR (( (uname[i]>='!' && uname[i]<='/') || uname[i]=='@' || uname[i]==' ') 14 | #define INVALID_CHAR ( (uname[i]>=':' && uname[i]<='?') || (uname[i]>='[' && uname[i]<='`') || (uname[i]>='{' && uname[i]<='~') ) ) 15 | 16 | 17 | struct { char name[20]; char pswd[20]; }user; /// DATA TYPE FOR USER /// 18 | 19 | 20 | 21 | int check(char upass[], char rpass[]) /// CHECKS WEATHER STRING PASSED ARE EQUAL 22 | { if(strlen(upass)==strlen(rpass)) 23 | { for(int i=0; i 10 | #include // For getch() function 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #define BOXLINES 70 // Total dotted lines in top and bottom 17 | #define LIVES 6 // Total chances players get 18 | #define PUNISH -50 // Score deduction value 19 | #define REWARD 100 // Score increment value 20 | 21 | // Function Declarations 22 | void reset(); 23 | void pickWord(); 24 | int playAgain(); 25 | char guessWord(); 26 | void dashBoard(); 27 | int setBlanks(char); 28 | int checkIfWon(); 29 | int isAlreadyGuessed(char); 30 | int isInWord(char, char*); 31 | void printMsg(char* word); 32 | void dottedLines(unsigned int n); 33 | 34 | // Global Variables 35 | int position, length, scores; 36 | char guess; 37 | 38 | // Hangman board representation 39 | char* board[] = {"", "| O\n| \n| \n", "| O\n| / \n| \n", "| O\n| /| \n| \n", "| O\n| /|\\\n| \n", "| O\n| /|\\\n| / \n", "| O\n| /|\\\n| / \\\n"}; 40 | char* blanks = NULL; 41 | char* secret = NULL; 42 | char* guessingBank = NULL; 43 | 44 | int main() { 45 | // Main game loop 46 | do { 47 | reset(); // Reset game variables 48 | while (position < LIVES) { 49 | system("cls"); 50 | dashBoard(); // Display Hangman dashboard 51 | 52 | // Prompt for guessing a letter 53 | guessAgain: 54 | guess = guessWord(); 55 | // Check if the letter has already been guessed 56 | if (isAlreadyGuessed(guess)) 57 | goto guessAgain; // If guessed letter is repeated, prompt for input again 58 | // Check if the guessed letter is in the secret word 59 | else if (setBlanks(guess)) { 60 | // Check if the player has won 61 | if (checkIfWon()) 62 | break; 63 | } else 64 | // If guessed letter is not in the secret word, decrease the lives of the player 65 | guessingBank[position++] = guess; 66 | } 67 | 68 | // If the player lost the game 69 | if (position >= LIVES) { 70 | strcpy(blanks, secret); 71 | system("cls"); 72 | dashBoard(); 73 | printf("\n"); 74 | printMsg("Try Again! You lost it man :("); 75 | } 76 | } while (playAgain()); // Prompt for a new game 77 | 78 | // Free dynamically allocated memory 79 | free(secret); 80 | free(blanks); 81 | free(guessingBank); 82 | return 0; 83 | } 84 | 85 | // Resets game variables 86 | void reset() { 87 | position = scores = 0; // Reset position and scores 88 | pickWord(); // Pick a new word for the game 89 | } 90 | 91 | // Display Hangman dashboard 92 | void dashBoard() { 93 | printMsg("HANGMAN: Recreated by Aashish Maharjan."); // Print game title 94 | printf("\n"); 95 | 96 | dottedLines(BOXLINES); // Print dotted lines 97 | printf("Chances: %d\t\tHistory: [%s]\n", LIVES - position, guessingBank); // Display remaining chances and guessing history 98 | printf("______\n"); 99 | printf("| |\n"); 100 | printf("%s", board[position]); // Display Hangman figure based on current position 101 | printf("|\n"); 102 | printf("|\n"); 103 | printf("------------------\n"); 104 | printf("\nSecret: %s\t\tScores: %d\n", blanks, scores); // Display secret word and scores 105 | dottedLines(BOXLINES); // Print dotted lines 106 | } 107 | 108 | // Prompt for guessing a letter 109 | char guessWord() { 110 | printf("\nGuess Letter: "); 111 | char c = getchar(); 112 | if (getchar() != '\n') { // Check if more than one character is entered 113 | printf("\n"); 114 | printMsg("Note: Please enter only one letter next time. It'll deduct scores!"); 115 | scores += PUNISH; // Deduct scores for incorrect input 116 | while (getchar() != '\n'); // Flush input buffer 117 | return guessWord(); // Prompt for input again 118 | } 119 | if (isalpha(c)) // Check if entered character is an alphabet 120 | return tolower(c); // Return lowercase version of entered character 121 | return guessWord(); // Prompt for input again 122 | } 123 | 124 | // Check if the guessed letter has already been guessed 125 | int isAlreadyGuessed(char guess) { 126 | if (isInWord(guess, guessingBank)) { // Check if guessed letter is in the guessing history 127 | printf("\n"); 128 | printMsg("You have already entered that letter. Repetition will deduct scores!"); 129 | scores += PUNISH; // Deduct scores for repeated guesses 130 | return 1; // Return true if letter is already guessed 131 | } 132 | return 0; // Return false if letter is not already guessed 133 | } 134 | 135 | // Check if secret word contains the guessed letter 136 | int isInWord(char guess, char* word) { 137 | for (int i = 0; i < position; i++) 138 | if (word[i] == guess) 139 | return 1; // Return true if guessed letter is found in secret word 140 | return 0; // Return false if guessed letter is not found in secret word 141 | } 142 | 143 | // Fill blanks in the secret word with the guessed letter 144 | int setBlanks(char guess) { 145 | int boolean = 0; 146 | for (int i = 0; i < length; i++) { 147 | if (secret[i] == guess) { 148 | blanks[i] = guess; // Fill blank space with guessed letter 149 | scores += REWARD; // Increment scores for correct guess 150 | boolean = 1; 151 | } 152 | } 153 | return boolean; // Return true if guessed letter is found in secret word 154 | } 155 | 156 | // Check if the player has won the game 157 | int checkIfWon() { 158 | if (strcmp(secret, blanks) == 0) { // Compare secret word with revealed word 159 | system("cls"); 160 | dashBoard(); 161 | printMsg("You got it man!"); // Print win message 162 | return 1; // Return true if player has won 163 | } 164 | return 0; // Return false if player has not won yet 165 | } 166 | 167 | // Prompt for playing the game again 168 | int playAgain() { 169 | printf("\nPress 'y' to continue: "); 170 | char c = getchar(); // Get user input 171 | while (getchar() != '\n'); // Flush input buffer 172 | system("cls"); // Clear screen 173 | return tolower(c) == 'y'; // Return true if user wants to play again, false otherwise 174 | } 175 | 176 | // Pick a random word from wordlist.txt 177 | void pickWord() { 178 | FILE* file; 179 | int lines = 0; 180 | char c = 0; 181 | file = fopen("wordlist.txt", "rb"); // Open wordlist file in binary mode 182 | 183 | // Count total number of words in the file 184 | while ((c = getc(file)) != EOF) 185 | if (c == '\n') 186 | lines++; 187 | srand(time(NULL)); // Seed random number generator 188 | 189 | // Select a random line number 190 | int randomLine = 1 + rand() % lines; 191 | int characters = 0; // Initialize character count for the selected word 192 | int seekWhere = 0; // Initialize seek position for fseek 193 | 194 | fseek(file, 0, SEEK_SET); // Move file pointer to the beginning 195 | 196 | lines = 0; // Reset line counter 197 | 198 | // Iterate through lines in the file 199 | while (lines < randomLine && (c = getc(file)) != EOF) { 200 | if (lines + 1 == randomLine) 201 | characters++; // Count characters for the selected word 202 | else 203 | seekWhere++; // Increment seek position 204 | if (c == '\n') 205 | lines++; // Increment line counter 206 | } 207 | 208 | // Adjust character count for carriage return and newline characters 209 | characters -= 2; // Contains '\r' and '\n' unnecessary characters (especially for Windows) 210 | length = characters; // Set the length of the secret word 211 | 212 | // Allocate memory for secret, blanks, and guessingBank 213 | if (secret == blanks == guessingBank == NULL) { 214 | secret = (char*)malloc(characters + 1); // Allocate memory for the secret word 215 | blanks = (char*)malloc(characters + 1); // Allocate memory for the blanks 216 | guessingBank = (char*)malloc(LIVES + 1); // Allocate memory for the guessing history 217 | } else { 218 | secret = realloc(secret, characters + 1); // Reallocate memory for the secret word 219 | blanks = realloc(blanks, characters + 1); // Reallocate memory for the blanks 220 | } 221 | 222 | // Set null terminator for secret, blanks, and guessingBank 223 | secret[characters] = blanks[characters] = guessingBank[6] = '\0'; 224 | 225 | fseek(file, seekWhere, SEEK_SET); // Position file pointer to the beginning of the selected word 226 | fread(secret, 1, characters, file); // Read the selected word from file to secret 227 | for (int i = 0; i < length; i++) 228 | blanks[i] = '*'; // Initialize blanks with '*' 229 | for (int i = 0; i < LIVES; i++) 230 | guessingBank[i] = ' '; // Initialize guessingBank with whitespace 231 | 232 | fclose(file); // Close the file 233 | } 234 | 235 | // Print n dotted lines 236 | void dottedLines(unsigned int n) { 237 | for (int i = 0; i < n; i++) 238 | printf("%c", '-'); 239 | printf("\n"); 240 | } 241 | 242 | // Print message with classic design 243 | void printMsg(char* word) { 244 | dottedLines(BOXLINES); 245 | printf("%s\n", word); 246 | dottedLines(BOXLINES); 247 | } 248 | -------------------------------------------------------------------------------- /Phonebook-C/infobook.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | void menu(void); 7 | void password(void); 8 | void namefun(void); 9 | void searchfun(void); 10 | void listfun(void); 11 | void modifyfun(void); 12 | void deletefun(void); 13 | void exitfun(void); 14 | void gotoxy(int x,int y){ 15 | COORD c; 16 | c.X=x; 17 | c.Y=y; 18 | SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c); 19 | } 20 | 21 | int main(){ 22 | system("color B"); 23 | password(); 24 | getch(); 25 | } 26 | 27 | void namefun(){ 28 | system("cls"); 29 | gotoxy(31,4); 30 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB NEW SECTION \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xB3"); 31 | FILE *fptr; 32 | char name[100]; 33 | char address[100]; 34 | char gmail[100]; 35 | double phone; 36 | char gender[8]; 37 | fptr=fopen("ebraj.txt","ab+");//ab+ gives us the ability of writing the function and add the second data in the existing one... 38 | if(fptr==NULL){ 39 | printf("Failed to create the required file."); 40 | } 41 | else{ 42 | gotoxy(31,6); 43 | printf("Name:\t"); 44 | gotoxy(52,6); 45 | gets(name); 46 | gotoxy(31,7); 47 | printf("Address:\t"); 48 | gotoxy(52,7); 49 | gets(address); 50 | gotoxy(31,8); 51 | printf("Gender:\t"); 52 | gotoxy(52,8); 53 | gets(gender); 54 | gotoxy(31,9); 55 | printf("Gmail:\t"); 56 | gotoxy(52,9); 57 | gets(gmail); 58 | gotoxy(31,10); 59 | printf("Phone Number:\t"); 60 | gotoxy(52,10); 61 | scanf("%lf",&phone); 62 | fprintf(fptr,"%s %s %s %s %.0lf\n",name,address,gender,gmail,phone); 63 | } 64 | fclose(fptr); 65 | system("cls"); 66 | char ch; 67 | gotoxy(31,4); 68 | printf("Do you wanna add more datas.Press y for that:"); 69 | Sleep(1000); 70 | fflush(stdin); 71 | while((ch=getch())=='y'){ 72 | menu(); 73 | } 74 | } 75 | 76 | void searchfun(){ 77 | FILE *fptr; 78 | int flag=0; 79 | int res; 80 | char name[100]; 81 | char address[100]; 82 | char gmail[100]; 83 | double phone; 84 | char gender[8]; 85 | char name1[100]; 86 | system("cls"); 87 | fflush(stdin); 88 | gotoxy(18,2); 89 | printf("\xDB\xDB\xDB Enter the name of the person you want to see the detail:: "); 90 | gets(name1); 91 | fptr=fopen("ebraj.txt","r"); 92 | //fflush(stdin); 93 | while(fscanf(fptr,"%s %s %s %s %lf\n",name,address,gender,gmail,&phone)!=EOF){ 94 | res=strcmp(name,name1); 95 | if(res==0){ 96 | gotoxy(39,4); 97 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB Record Found \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xB3"); 98 | gotoxy(28,5); 99 | printf("----------------------------------------"); 100 | gotoxy(31,6.5); 101 | printf("\xB3\xB2\xB2\xB2 Name:\t%s",name); 102 | gotoxy(31,7); 103 | printf("\xB3\xB2\xB2\xB2 Address:\t%s",address); 104 | gotoxy(31,8); 105 | printf("\xB3\xB2\xB2\xB2 Gender:\t%s",gender); 106 | gotoxy(31,9); 107 | printf("\xB3\xB2\xB2\xB2 Gmail:\t%s",gmail); 108 | gotoxy(31,10); 109 | printf("\xB3\xB2\xB2\xB2 Phone Number:\t%.0lf",phone); 110 | gotoxy(31,11); 111 | printf("----------------------------------------"); 112 | flag=1; 113 | Sleep(1000); 114 | gotoxy(18,12); 115 | printf("Enter y for menu option."); 116 | while(getch()=='y'){ 117 | menu(); 118 | } 119 | } 120 | } 121 | if(flag==0){ 122 | system("cls"); 123 | gotoxy(39,4); 124 | printf("No record found.");; 125 | gotoxy(39,6); 126 | printf("Enter a to enter file again or double y key to open menu section:"); 127 | if(getch()=='a'){ 128 | system("cls"); 129 | searchfun(); 130 | } 131 | 132 | } 133 | 134 | 135 | fclose(fptr); 136 | } 137 | void listfun(){ 138 | FILE *fptr; 139 | char name[100],address[100],gmail[100],gender[8]; 140 | double phone; 141 | int f; 142 | fptr=fopen("ebraj.txt","r"); 143 | system("cls"); 144 | gotoxy(31,2); 145 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB LIST SECTION OPENED \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xB3"); 146 | printf("\n"); 147 | while(fscanf(fptr,"%s %s %s %s %lf",name,address,gender,gmail,&phone)!=EOF){ 148 | 149 | printf("------------------------------------------\n"); 150 | printf("Name:%s\n",name); 151 | printf("Address:%s\n",address); 152 | printf("Gender:%s\n",gender); 153 | printf("Gmail:%s\n",gmail); 154 | printf("Phone:%.0lf\n",phone); 155 | f=1; 156 | printf("------------------------------------------"); 157 | printf("\n\n"); 158 | } 159 | Sleep(1000); 160 | printf("Enter y for menu section:"); 161 | while(getch()=='y'){ 162 | menu(); 163 | } 164 | fclose(fptr); 165 | } 166 | 167 | 168 | 169 | void modifyfun(){ 170 | FILE *fptr,*fptr1; 171 | char name[100],address[100],gmail[100],gmail1[100],address1[100],name1[100],gender[8],gender1[8]; 172 | int res,f=0; 173 | double phone,phone1; 174 | fptr=fopen("ebraj.txt","r"); 175 | fptr1=fopen("temp.txt","a"); 176 | system("cls"); 177 | gotoxy(31,4); 178 | printf("Enter the name: "); 179 | gets(name1); 180 | system("cls"); 181 | while(fscanf(fptr,"%s %s %s %s %lf\n",name,address,gender,gmail,&phone)!=EOF){ 182 | res=strcmp(name,name1); 183 | if(res==0) 184 | { 185 | f=1; 186 | gotoxy(31,4); 187 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB MODIFY SECTION OPENED \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xB3"); 188 | gotoxy(31,6); 189 | printf("Enter the new address:"); 190 | scanf("%s",address1); 191 | gotoxy(31,7); 192 | printf("Enter the gender:"); 193 | scanf("%s",gender1); 194 | gotoxy(31,8); 195 | printf("Enter the new gmail:"); 196 | scanf("%s",gmail1); 197 | gotoxy(31,9); 198 | printf("Enter the new phone number:"); 199 | scanf("%lf",&phone1); 200 | fprintf(fptr1,"%s %s %s %s %.0lf\n",name,address1,gender1,gmail1,phone1); 201 | 202 | }else{ 203 | fprintf(fptr1,"%s %s %s %s %.0lf\n",name,address,gender,gmail,phone); 204 | } 205 | } 206 | if(f==0){ 207 | printf("Record Not found."); 208 | } 209 | fclose(fptr); 210 | fclose(fptr1); 211 | fptr=fopen("ebraj.txt","w"); 212 | fclose(fptr); 213 | fptr=fopen("ebraj.txt","a"); 214 | fptr1=fopen("temp.txt","r"); 215 | while(fscanf(fptr1,"%s %s %s %s %lf\n",name,address,gender,gmail,&phone)!=EOF){ 216 | fprintf(fptr,"%s %s %s %s %.0lf\n",name,address,gender,gmail,phone); 217 | 218 | } 219 | 220 | fclose(fptr); 221 | fclose(fptr1); 222 | fptr1=fopen("temp.txt","w"); 223 | fclose(fptr1); 224 | printf("\n\nPress y for menu option."); 225 | fflush(stdin); 226 | if(getch()=='y'){ 227 | menu(); 228 | } 229 | } 230 | void deletefun(){ 231 | FILE *fptr,*fptr1; 232 | char name[100],address[100],gmail[100],gmail1[100],address1[100],name1[100],gender[8]; 233 | int res,f=0; 234 | double phone,phone1; 235 | fptr=fopen("ebraj.txt","r"); 236 | fptr1=fopen("temp.txt","a"); 237 | system("cls"); 238 | gotoxy(31,4); 239 | printf("Enter the CONTACT name that you want to delete: "); 240 | gets(name1); 241 | system("cls"); 242 | while(fscanf(fptr,"%s %s %s %s %lf\n",name,address,gender,gmail,&phone)!=EOF){ 243 | res=strcmp(name,name1); 244 | if(res==0) 245 | { 246 | f=1; 247 | printf("Record deleted successfully"); 248 | 249 | }else{ 250 | fprintf(fptr1,"%s %s %s %s %.0lf\n",name,address,gender,gmail,phone); 251 | } 252 | } 253 | if(f==0){ 254 | printf("Record Not found."); 255 | } 256 | fclose(fptr); 257 | fclose(fptr1); 258 | fptr=fopen("ebraj.txt","w"); 259 | fclose(fptr); 260 | fptr=fopen("ebraj.txt","a"); 261 | fptr1=fopen("temp.txt","r"); 262 | while(fscanf(fptr1,"%s %s %s %s %lf\n",name,address,gender,gmail,&phone)!=EOF){ 263 | fprintf(fptr,"%s %s %s %s %.0lf\n",name,address,gender,gmail,phone); 264 | 265 | } 266 | 267 | fclose(fptr); 268 | fclose(fptr1); 269 | fptr1=fopen("temp.txt","w"); 270 | fclose(fptr1); 271 | printf("\n\nPress y for menu option."); 272 | fflush(stdin); 273 | if(getch()=='y'){ 274 | menu(); 275 | }; 276 | } 277 | void exitfun(){ 278 | system("cls"); 279 | gotoxy(31,4); 280 | printf("\xDB\xDB\xDB\xDB TEAM MEMBERS \xDB\xDB\xDB\xDB"); 281 | gotoxy(31,6); 282 | printf("\xDB EBRAJ GURUNG."); 283 | gotoxy(31,8); 284 | printf("\xDB BEEKASH BASAULA."); 285 | gotoxy(31,10); 286 | printf("\xDB SAMUNDRA POUDEL."); 287 | gotoxy(31,12); 288 | printf("\xDB SAGAR DHAKAL."); 289 | } 290 | void password(void){ 291 | char passwords[20]={"ebrajdon"}; 292 | gotoxy(22,2); 293 | int j; 294 | int z; 295 | char name[40]="Authorized Person Only"; 296 | z=strlen(name); 297 | for(j=0;j<=16;j++){ 298 | Sleep(50); 299 | printf("\xDB"); 300 | } 301 | for(j=0;j<=z;j++){ 302 | Sleep(60); 303 | printf(" %c",name[j]); 304 | } 305 | for(j=0;j<=16;j++){ 306 | Sleep(50); 307 | printf("\xDB"); 308 | } 309 | gotoxy(30,4); 310 | printf("Password:"); 311 | char ch,pass[20]; 312 | char w='*'; 313 | int i=0; 314 | while(ch!=13 && i < 20){ 315 | ch=getch(); 316 | if(ch!=13 && ch!=8){ 317 | printf("%c",w); 318 | pass[i]=ch; 319 | i++; 320 | } 321 | } 322 | pass[i]='\0'; 323 | if(strcmp(pass,passwords)==0){ 324 | gotoxy(30,6); 325 | printf("CORRECT PASSWORD."); 326 | Sleep(1000); 327 | menu(); 328 | } 329 | else{ 330 | gotoxy(30,6); 331 | printf("You entered the wrong password."); 332 | Sleep(700); 333 | system("cls"); 334 | password(); 335 | } 336 | 337 | } 338 | 339 | 340 | void menu(){ 341 | system("cls"); 342 | gotoxy(30,1); 343 | printf("\xB3\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 PHONEBOOK DIRECTORY \xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB3"); 344 | gotoxy(31,4); 345 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 1.Add New"); 346 | gotoxy(31,7); 347 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 2.Search"); 348 | gotoxy(31,10); 349 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 3.List"); 350 | gotoxy(31,13); 351 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 4.Modify"); 352 | gotoxy(31,16); 353 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 5.Delete"); 354 | gotoxy(31,19); 355 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 6.Exit"); 356 | switch(getch()){ 357 | case '1': 358 | namefun(); 359 | break; 360 | case '2': 361 | searchfun(); 362 | break; 363 | case '3': 364 | listfun(); 365 | break; 366 | case '4': 367 | modifyfun(); 368 | break; 369 | case '5': 370 | deletefun(); 371 | break; 372 | case '6': 373 | exitfun(); 374 | break; 375 | default: 376 | system("cls"); 377 | printf("Invalid Enter."); 378 | getch(); 379 | } 380 | } 381 | 382 | 383 | -------------------------------------------------------------------------------- /Hotel-Management-System-C/HMSC.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | void add(); //FUNCTIONS 9 | void list(); 10 | void edit(); //GLOBALLY DECLARED FUNCTIONS N VARIABLE 11 | void delete1(); 12 | void search(); 13 | 14 | void setcolor(int ForgC) 15 | { WORD wColor; 16 | HANDLE hStdOut=GetStdHandle(STD_OUTPUT_HANDLE); 17 | CONSOLE_SCREEN_BUFFER_INFO csbi; 18 | 19 | if(GetConsoleScreenBufferInfo(hStdOut,&csbi)) 20 | { 21 | wColor=(csbi.wAttributes & 0xB0)+(ForgC & 0x0B); 22 | // SetConsoleTextAttributes(hStdOut,wColor); 23 | SetConsoleTextAttribute(hStdOut,wColor); 24 | 25 | } 26 | } 27 | 28 | void login() 29 | { 30 | 31 | int a=0,i=0; 32 | char uname[10],c=' '; 33 | char pword[10],code[10]; 34 | char user[10]="user"; 35 | char pass[10]="pass"; 36 | do 37 | { 38 | system("cls"); 39 | 40 | printf("\n ************************** LOGIN FORM ************************** "); 41 | printf(" \n ENTER USERNAME:-"); 42 | scanf("%s", &uname); 43 | printf(" \n ENTER PASSWORD:-"); 44 | while(i<10) 45 | { 46 | pword[i]=getch(); 47 | c=pword[i]; 48 | if(c==13) break; 49 | else printf("*"); 50 | i++; 51 | } 52 | pword[i]='\0'; 53 | //char code=pword; 54 | i=0; 55 | //scanf("%s",&pword); 56 | if(strcmp(uname,user)==0 && strcmp(pword,pass)==0) 57 | { 58 | printf(" \n\n\n WELCOME !!!! LOGIN IS SUCCESSFUL"); 59 | 60 | break; 61 | } 62 | else 63 | { 64 | printf("\n SORRY !!!! LOGIN IS UNSUCESSFUL"); 65 | a++; 66 | 67 | getch(); 68 | 69 | } 70 | } 71 | while(a<=2); 72 | if (a>2) 73 | { 74 | printf("\nSorry you have entered the wrong username and password for four times!!!"); 75 | 76 | getch(); 77 | 78 | } 79 | system("cls"); 80 | } 81 | 82 | struct CustomerDetails //STRUCTURE DECLARATION 83 | { 84 | char roomnumber[10]; 85 | char name[20]; 86 | char address[25]; 87 | char phonenumber[15]; 88 | char nationality[15]; 89 | char email[20]; 90 | char period[10]; 91 | char arrivaldate[10]; 92 | }s; 93 | 94 | int main(){ // MAIN FUNCTION 95 | int i=0; 96 | 97 | time_t t; 98 | time(&t); 99 | char customername; 100 | char choice; 101 | 102 | system("cls"); // FOR CLEARING SCREEN 103 | setcolor(15); 104 | printf(" -------------------------------------------------------------------------\n"); 105 | printf("| |\n"); 106 | printf("| |\n"); 107 | printf("| OOOOOO OOOOOO OOOOOO OOOOOO OOOOOO OOOOOO O O OOOOOOO OOOOOO |\n"); 108 | printf("| O O O O O O O O O O O O |\n"); 109 | printf("| O OOOOO OOOOOO OOOOO OOOOO O O O O O O OOOOO OOOOOO |\n"); 110 | printf("| O O O O O O O O O O O O O O |\n"); 111 | printf("| OOOOOO O O OOOOOO OOOOOO O OOOOOO O O O OOOOOO OOOOOO |\n"); 112 | printf("| |\n"); 113 | printf(" -------------------------------------------------------------------------\n"); 114 | printf("\t\t*************************************************\n"); 115 | printf("\t\t* *\n"); 116 | printf("\t\t* ----------------------------- *\n"); 117 | printf("\t\t* WELCOME TO HOTEL DESERT CAVE *\n"); 118 | printf("\t\t* ----------------------------- *\n"); 119 | printf("\t\t* *\n"); 120 | printf("\t\t* *\n"); 121 | printf("\t\t* *\n"); 122 | printf("\t\t* Brought To You By code-projects.org *\n"); 123 | printf("\t\t* ESP,XYZ *\n"); 124 | printf("\t\t* CONTACT US:18-87454575552,035455852 *\n"); 125 | printf("\t\t*************************************************\n\n\n"); 126 | for(i=0;i<80;i++) 127 | printf("-"); 128 | printf("\nCurrent date and time : %s",ctime(&t)); 129 | for(i=0;i<80;i++) 130 | printf("-"); 131 | printf(" \n Press any key to continue:"); 132 | 133 | getch(); 134 | system("cls"); 135 | login(); 136 | system("cls"); 137 | while (1) // INFINITE LOOP 138 | { 139 | system("cls"); 140 | setcolor(10); 141 | for(i=0;i<80;i++) 142 | printf("-"); 143 | printf("\n"); 144 | printf(" ****************************** |MAIN MENU| ***************************** \n"); 145 | for(i=0;i<80;i++) 146 | printf("-"); 147 | printf("\n"); 148 | setcolor(10); 149 | printf("\t\t *Please enter your choice for menu*:"); 150 | printf("\n\n"); 151 | printf(" \n Enter 1 -> Book a room"); 152 | printf("\n------------------------"); 153 | printf(" \n Enter 2 -> View Customer Record"); 154 | printf("\n----------------------------------"); 155 | printf(" \n Enter 3 -> Delete Customer Record"); 156 | printf("\n-----------------------------------"); 157 | printf(" \n Enter 4 -> Search Customer Record"); 158 | printf("\n-----------------------------------"); 159 | printf(" \n Enter 5 -> Edit Record"); 160 | printf("\n-----------------------"); 161 | printf(" \n Enter 6 -> Exit"); 162 | printf("\n-----------------"); 163 | printf("\n"); 164 | for(i=0;i<80;i++) 165 | printf("-"); 166 | printf("\nCurrent date and time : %s",ctime(&t)); 167 | for(i=0;i<80;i++) 168 | printf("-"); 169 | 170 | choice=getche(); 171 | choice=toupper(choice); 172 | switch(choice) // SWITCH STATEMENT 173 | { 174 | case '1': 175 | add();break; 176 | case '2': 177 | list();break; 178 | case '3': 179 | delete1();break; 180 | case '4': 181 | search();break; 182 | case '5': 183 | edit();break; 184 | case '6': 185 | system("cls"); 186 | printf("\n\n\t *****THANK YOU*****"); 187 | printf("\n\t FOR TRUSTING OUR SERVICE"); 188 | // Sleep(2000); 189 | exit(0); 190 | break; 191 | default: 192 | system("cls"); 193 | printf("Incorrect Input"); 194 | printf("\n Press any key to continue"); 195 | getch(); 196 | } 197 | } 198 | } 199 | 200 | void add() 201 | { 202 | FILE *f; 203 | char test; 204 | f=fopen("add.txt","a+"); 205 | if(f==0) 206 | { f=fopen("add.txt","w+"); 207 | system("cls"); 208 | printf("Please hold on while we set our database in your computer!!"); 209 | printf("\n Process completed press any key to continue!! "); 210 | getch(); 211 | } 212 | while(1) 213 | { 214 | system("cls"); 215 | printf("\n Enter Customer Details:"); 216 | printf("\n**************************"); 217 | printf("\n Enter Room number:\n"); 218 | scanf("\n%s",s.roomnumber); 219 | fflush(stdin); 220 | printf("Enter Name:\n"); 221 | scanf("%s",s.name); 222 | printf("Enter Address:\n"); 223 | scanf("%s",s.address); 224 | printf("Enter Phone Number:\n"); 225 | scanf("%s",s.phonenumber); 226 | printf("Enter Nationality:\n"); 227 | scanf("%s",s.nationality); 228 | printf("Enter Email:\n"); 229 | scanf(" %s",s.email); 230 | printf("Enter Period(\'x\'days):\n"); 231 | scanf("%s",&s.period); 232 | printf("Enter Arrival date(dd\\mm\\yyyy):\n"); 233 | scanf("%s",&s.arrivaldate); 234 | fwrite(&s,sizeof(s),1,f); 235 | fflush(stdin); 236 | printf("\n\n1 Room is successfully booked!!"); 237 | printf("\n Press esc key to exit, any other key to add another customer detail:"); 238 | test=getche(); 239 | if(test==27) 240 | break; 241 | 242 | } 243 | fclose(f); 244 | } 245 | 246 | void list() 247 | { 248 | FILE *f; 249 | int i; 250 | if((f=fopen("add.txt","r"))==NULL) 251 | exit(0); 252 | system("cls"); 253 | printf("ROOM "); 254 | printf("NAME\t "); 255 | printf("\tADDRESS "); 256 | printf("\tPHONENUMBER "); 257 | printf("\tNATIONALITY "); 258 | printf("\tEMAIL "); 259 | printf("\t\t PERIOD "); 260 | printf("\t ARRIVALDATE \n"); 261 | 262 | for(i=0;i<118;i++) 263 | printf("-"); 264 | while(fread(&s,sizeof(s),1,f)==1) 265 | { 266 | /*printf("ROOMNUMBER :\t%s\n",s.roomnumber); 267 | printf("NAME:\t%s\n",,s.name); 268 | printf("ADDRESS:\t%s\n",s.address); 269 | printf("PHONENUMBER:\t%s\n",s.phonenumber); 270 | printf("NATIONALITY \n");*/ 271 | printf("\n%s \t%s \t\t%s \t\t%s \t%s \t%s \t %s \t %s",s.roomnumber, s.name , s.address , s.phonenumber ,s.nationality ,s.email,s.period, s.arrivaldate); 272 | } 273 | printf("\n"); 274 | for(i=0;i<118;i++) 275 | printf("-"); 276 | 277 | fclose(f); 278 | getch(); 279 | } 280 | 281 | void delete1() 282 | { 283 | FILE *f,*t; 284 | int i=1; 285 | char roomnumber[20]; 286 | if((t=fopen("temp.txt","w"))==NULL) 287 | exit(0); 288 | if((f=fopen("add.txt","r"))==NULL) 289 | exit(0); 290 | system("cls"); 291 | printf("Enter the Room Number of the hotel to be deleted from the database: \n"); 292 | fflush(stdin); 293 | scanf("%s",roomnumber); 294 | while(fread(&s,sizeof(s),1,f)==1) 295 | { 296 | if(strcmp(s.roomnumber,roomnumber)==0) 297 | { i=0; 298 | continue; 299 | } 300 | else 301 | fwrite(&s,sizeof(s),1,t); 302 | } 303 | if(i==1) 304 | { 305 | printf("\n\n Records of Customer in this Room number is not found!!"); 306 | //remove("E:/file.txt"); 307 | //rename("E:/temp.txt","E:/file.txt"); 308 | getch(); 309 | fclose(f); 310 | fclose(t); 311 | main(); 312 | } 313 | fclose(f); 314 | fclose(t); 315 | remove("add.txt"); 316 | rename("temp.txt","add.txt"); 317 | printf("\n\nThe Customer is successfully removed...."); 318 | fclose(f); 319 | fclose(t); 320 | getch(); 321 | } 322 | 323 | void search() 324 | { 325 | system("cls"); 326 | FILE *f; 327 | char roomnumber[20]; 328 | int flag=1; 329 | f=fopen("add.txt","r+"); 330 | if(f==0) 331 | exit(0); 332 | fflush(stdin); 333 | printf("Enter Room number of the customer to search its details: \n"); 334 | scanf("%s", roomnumber); 335 | while(fread(&s,sizeof(s),1,f)==1) 336 | { 337 | if(strcmp(s.roomnumber,roomnumber)==0){ 338 | flag=0; 339 | printf("\n\tRecord Found\n "); 340 | printf("\nRoom Number:\t%s",s.roomnumber); 341 | printf("\nName:\t%s",s.name); 342 | printf("\nAddress:\t%s",s.address); 343 | printf("\nPhone number:\t%s",s.phonenumber); 344 | printf("\nNationality:\t%s",s.nationality); 345 | printf("\nEmail:\t%s",s.email); 346 | printf("\nPeriod:\t%s",s.period); 347 | printf("\nArrival date:\t%s",s.arrivaldate); 348 | flag=0; 349 | break; 350 | } 351 | } 352 | if(flag==1){ 353 | printf("\n\tRequested Customer could not be found!"); 354 | } 355 | getch(); 356 | fclose(f); 357 | } 358 | 359 | void edit() 360 | { 361 | FILE *f; 362 | int k=1; 363 | char roomnumber[20]; 364 | long int size=sizeof(s); 365 | if((f=fopen("add.txt","r+"))==NULL) 366 | exit(0); 367 | system("cls"); 368 | printf("Enter Room number of the customer to edit:\n\n"); 369 | scanf("%[^\n]",roomnumber); 370 | fflush(stdin); 371 | while(fread(&s,sizeof(s),1,f)==1) 372 | { 373 | if(strcmp(s.roomnumber,roomnumber)==0) 374 | { 375 | k=0; 376 | printf("\nEnter Room Number :"); 377 | gets(s.roomnumber); 378 | printf("\nEnter Name :"); 379 | fflush(stdin); 380 | scanf("%s",&s.name); 381 | printf("\nEnter Address :"); 382 | scanf("%s",&s.address); 383 | printf("\nEnter Phone number :"); 384 | scanf("%f",&s.phonenumber); 385 | printf("\nEnter Nationality :"); 386 | scanf("%s",&s.nationality); 387 | printf("\nEnter Email :"); 388 | scanf("%s",&s.email); 389 | printf("\nEnter Period :"); 390 | scanf("%s",&s.period); 391 | printf("\nEnter Arrival date :"); 392 | scanf("%s",&s.arrivaldate); 393 | fseek(f,size,SEEK_CUR); //to go to desired position infile 394 | fwrite(&s,sizeof(s),1,f); 395 | break; 396 | } 397 | } 398 | if(k==1){ 399 | printf("\n\nTHE RECORD DOESN'T EXIST!!!!"); 400 | fclose(f); 401 | getch(); 402 | }else{ 403 | fclose(f); 404 | printf("\n\n\t\tYOUR RECORD IS SUCCESSFULLY EDITED!!!"); 405 | getch(); 406 | } 407 | } 408 | -------------------------------------------------------------------------------- /Bus-Reservation-in-C/Bus Reserevation Final C_Language/Bus_Reservation_System.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | char ch[10][130]={"Manglore Express","Karwar Express","Airavat Express","SeaBird Express","Newport Express","VRL Express"}; 5 | char name[32][100]={'\0'}; 6 | char number[32][2]={'\0'}; 7 | int num1[32]={0}; 8 | int trno; 9 | void bus();//for list of bus 10 | void name_number(int booking,char numstr[100]); 11 | void booking();//for booking the tickets 12 | int read_number(int trno);//for reading the number from the file 13 | void read_name(int trno);//for reading the name from the file 14 | void status();//for printing the status by user input 15 | void status_1(int trno);//for printing the status while booking ticket 16 | void cancle(); 17 | 18 | int main() 19 | { 20 | login(); 21 | int num,i; 22 | do{ 23 | system("cls"); 24 | printf("\n\n\n"); 25 | printf("====================================== WELCOME TO BUS RESERVATION SYSTEM ======================================\n\n\n"); 26 | printf("\t\t\t\t\t[1]=> View Bus List\n"); 27 | printf("\n"); 28 | printf("\t\t\t\t\t[2]=> Book Tickets\n"); 29 | printf("\n"); 30 | printf("\t\t\t\t\t[3]=> Cancle Booking\n"); 31 | printf("\n"); 32 | printf("\t\t\t\t\t[4]=> Bus Status Board\n"); 33 | printf("\n"); 34 | printf("\t\t\t\t\t[5]=> Exit\n\n"); 35 | printf("===============================================================================================================\n\n"); 36 | printf("\t\t\tEnter Your Choice:: "); 37 | scanf("%d",&num); 38 | switch(num) 39 | { 40 | case 1: 41 | bus();//for list of bus 42 | break; 43 | case 2: 44 | booking();//for booking the tickets 45 | break; 46 | case 3: 47 | cancle(); 48 | break; 49 | case 4: 50 | status(); 51 | break; 52 | } 53 | getch(); 54 | }while(num != 5); 55 | system("CLS"); 56 | printf("\t----------------------------------------------------------------------------------------------------------\n"); 57 | printf("\t\t\t\t\tThank You For Using This System\t\t\t\t\t\t\n"); 58 | printf("\t----------------------------------------------------------------------------------------------------------\n"); 59 | getch(); 60 | return 0; 61 | } 62 | 63 | 64 | void bus() 65 | { 66 | system("cls"); 67 | printf("\n\n\n"); 68 | printf("=========================================== BUS RESERVATION SYSTEM ============================================\n\n\n"); 69 | printf("\t\t\t\t\t[1] => %s\n",ch[0]); 70 | printf("\n"); 71 | printf("\t\t\t\t\t[2] => %s\n",ch[1]); 72 | printf("\n"); 73 | printf("\t\t\t\t\t[3] => %s\n",ch[2]); 74 | printf("\n"); 75 | printf("\t\t\t\t\t[4] => %s\n",ch[3]); 76 | printf("\n"); 77 | printf("\t\t\t\t\t[5] => %s\n",ch[4]); 78 | } 79 | 80 | void booking() 81 | { 82 | 83 | int i=0; 84 | char numstr[100]; 85 | system("cls"); 86 | printf("=========================================== BUS RESERVATION SYSTEM ============================================\n\n\n");//for entering bus number 87 | bus();//for seeing bus list 88 | printf("Enter the Bus number:--->"); 89 | scanf("%d",&trno); 90 | system("cls"); 91 | printf("=========================================== BUS RESERVATION SYSTEM ============================================\n\n\n");//for selecting seat 92 | printf("Your Bus Number is %d ********** %s",trno,ch[trno-1]); 93 | status_1(trno); 94 | FILE *f1, *fopen();//for reading the seats from the user. 95 | char str1[80]="32",str2[4],str3[4]; 96 | int seat1,seat2,booking=0; 97 | if(trno == 1) 98 | { 99 | f1 = fopen("tr1.txt","r+"); 100 | fgets(str1,80,f1); 101 | fclose(f1); 102 | }else if(trno == 2) 103 | { 104 | f1 = fopen("tr2.txt","r+"); 105 | fgets(str1,80,f1); 106 | fclose(f1); 107 | }else if(trno == 3) 108 | { 109 | f1 = fopen("tr3.txt","r+"); 110 | fgets(str1,80,f1); 111 | fclose(f1); 112 | } 113 | else if(trno == 4) 114 | { 115 | f1 = fopen("tr4.txt","r+"); 116 | fgets(str1,80,f1); 117 | fclose(f1); 118 | } 119 | else if(trno == 5) 120 | { 121 | f1 = fopen("tr5.txt","r+"); 122 | fgets(str1,80,f1); 123 | fclose(f1); 124 | } 125 | seat1=atoi(str1);//covert the string into number 126 | if(seat1 <= 0) 127 | { 128 | printf("There is no blank seat in this bus "); 129 | }else 130 | { 131 | printf("\n\n\n\t\t\t\tAvailable Seats:------>%d\n",seat1); 132 | printf("\n\t\t\t\tNumber of Tickets:----->"); 133 | scanf("%d",&booking); 134 | printf("\n"); 135 | 136 | seat1=seat1-booking; 137 | itoa(trno,numstr,10); 138 | name_number(booking,numstr); 139 | printf("\n\t\t\t\tThe Total booking amount is %d",200*booking); 140 | itoa(seat1, str1, 10); 141 | //for reading the seats from the user. 142 | if(trno == 1) 143 | { 144 | f1 = fopen("tr1.txt","w"); 145 | fputs(str1,f1); 146 | fclose(f1); 147 | } 148 | else if(trno == 2) 149 | { 150 | f1 = fopen("tr2.txt","w"); 151 | fputs(str1,f1); 152 | fclose(f1); 153 | } 154 | else if(trno == 3) 155 | { 156 | f1 = fopen("tr3.txt","w"); 157 | fputs(str1,f1); 158 | fclose(f1); 159 | } 160 | else if(trno == 4) 161 | { 162 | f1 = fopen("tr4.txt","w"); 163 | fputs(str1,f1); 164 | fclose(f1); 165 | } 166 | else if(trno == 5) 167 | { 168 | f1 = fopen("tr5.txt","w"); 169 | fputs(str1,f1); 170 | fclose(f1); 171 | } 172 | } 173 | } 174 | 175 | 176 | 177 | void name_number(int booking,char numstr[100]) 178 | { 179 | char tempstr[100],tempstr1[12]="status",tempstr2[12]="number"; 180 | int number; 181 | FILE *a,*b; 182 | int i=0; 183 | strcat(numstr,".txt"); 184 | strcat(tempstr1,numstr); 185 | strcat(tempstr2,numstr); 186 | a = fopen(tempstr1,"a");//for open the file to write the name in the file 187 | b = fopen(tempstr2,"a");//for open the file for writing the number in the file 188 | for(i=0; i"); 192 | scanf("%d",&number); 193 | printf("\t\t\t\tEnter the name of person:--->"); 194 | scanf("%s",name[number-1]); 195 | printf("\n======================================================================================================\n\n"); 196 | printf("\n"); 197 | itoa(number, tempstr, 10); 198 | fprintf(a,"%s ",name[number-1]); 199 | fprintf(b,"%s ",tempstr); 200 | 201 | } 202 | fclose(a); 203 | fclose(b); 204 | } 205 | 206 | 207 | 208 | int read_number(int trno)//for putting the numeric value in the array 209 | { 210 | char tempstr[100],tempstr2[12]="number"; 211 | FILE *a,*b; 212 | char numstr[100]; 213 | int i=0,j=0,k; 214 | itoa(trno,numstr,10); 215 | strcat(numstr,".txt"); 216 | strcat(tempstr2,numstr); 217 | a = fopen(tempstr2,"a+");//for open the file to write the name in the file 218 | while(!feof(a)) 219 | { 220 | number[i][j] = fgetc(a); 221 | 222 | if(number[i][j] == ' ') 223 | { 224 | j=0; 225 | i++; 226 | } 227 | else 228 | { 229 | j++; 230 | } 231 | } 232 | k=i; 233 | for(i=0; i"); 278 | scanf("%d",&trno); 279 | j=read_number(trno); 280 | read_name(trno); 281 | printf("____________________________________________________________________________________________________________________\n"); 282 | printf(" Bus.no-->%d---->%s \n",trno,ch[trno-1]); 283 | printf("____________________________________________________________________________________________________________________\n"); 284 | char tempname[33][10]={"Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty ","Empty "}; 285 | for(i=0; i"); 332 | scanf("%d",&trno); 333 | itoa(trno,numstr,10); 334 | strcat(numstr,".txt"); 335 | strcat(tempstr1,numstr); 336 | strcat(tempstr2,numstr); 337 | read_number(trno); 338 | read_name(trno); 339 | status_1(trno); 340 | printf("Enter the seat number:--->"); 341 | scanf("%d",&seat_no); 342 | FILE *a,*b; 343 | a = fopen(tempstr1,"w+"); 344 | b = fopen(tempstr2,"w+"); 345 | for(i=0; i<32; i++) 346 | { 347 | if(num1[i] == seat_no) 348 | { 349 | for(j=0; j<32; j++) 350 | { 351 | if(num1[j] != seat_no && num1[j] != 0) 352 | { 353 | fprintf(b,"%d ",num1[j]); 354 | fprintf(a,"%s",name[j]); 355 | } 356 | else if(num1[j] == seat_no && num1[j] != 0) 357 | { 358 | strcpy(name[j],"Empty "); 359 | } 360 | } 361 | } 362 | } 363 | fclose(a); 364 | fclose(b); 365 | printf("\n\n"); 366 | printf("======================================================================================================\n"); 367 | printf("\t\t\t\tYour 200 rupees has been Returned\t\t\t\n"); 368 | printf("======================================================================================================\n"); 369 | } 370 | 371 | 372 | void login() 373 | { 374 | int a=0,i=0; 375 | char uname[10],c=' '; 376 | char pword[10],code[10]; 377 | char user[10]="user"; 378 | char pass[10]="pass"; 379 | do 380 | { 381 | system("cls"); 382 | 383 | printf("\n ========================= LOGIN FORM ========================= "); 384 | printf(" \n ENTER USERNAME:-"); 385 | scanf("%s", &uname); 386 | printf(" \n ENTER PASSWORD:-"); 387 | while(i<10) 388 | { 389 | pword[i]=getch(); 390 | c=pword[i]; 391 | if(c==13) break; 392 | else printf("*"); 393 | i++; 394 | } 395 | pword[i]='\0'; 396 | //char code=pword; 397 | i=0; 398 | //scanf("%s",&pword); 399 | if(strcmp(uname,"user")==0 && strcmp(pword,"pass")==0) 400 | { 401 | printf(" \n\n\n WELCOME TO OUR SYSTEM !!!! LOGIN IS SUCCESSFUL"); 402 | printf("\n\n\n\t\t\t\tPress any key to continue..."); 403 | getch();//holds the screen 404 | break; 405 | } 406 | else 407 | { 408 | printf("\n SORRY !!!! LOGIN IS UNSUCESSFUL"); 409 | a++; 410 | 411 | getch();//holds the screen 412 | 413 | } 414 | } 415 | while(a<=2); 416 | if (a>2) 417 | { 418 | printf("\nSorry you have entered the wrong username and password for four times!!!"); 419 | 420 | getch(); 421 | 422 | } 423 | system("cls"); 424 | } 425 | -------------------------------------------------------------------------------- /Bank Account System/Main.c: -------------------------------------------------------------------------------- 1 | // C program to implement 2 | // the above approach 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | // Declaring all the functions 10 | void checkbalance(char*); 11 | void transfermoney(void); 12 | void display(char*); 13 | void person(char*); 14 | void login(void); 15 | void loginsu(void); 16 | void account(void); 17 | void accountcreated(void); 18 | void afterlogin(void); 19 | void logout(void); 20 | 21 | // Declaring gotoxy 22 | // function for setting 23 | // cursor position 24 | void gotoxy(int x, int y) 25 | { 26 | COORD c; 27 | c.X = x; 28 | c.Y = y; 29 | 30 | SetConsoleCursorPosition( 31 | GetStdHandle(STD_OUTPUT_HANDLE), c); 32 | } 33 | 34 | // Creating a structure to store 35 | // data of the user 36 | struct pass { 37 | char username[50]; 38 | int date, month, year; 39 | char pnumber[15]; 40 | char adharnum[20]; 41 | char fname[20]; 42 | char lname[20]; 43 | char fathname[20]; 44 | char mothname[20]; 45 | char address[50]; 46 | char typeaccount[20]; 47 | }; 48 | 49 | // Structure to keep track 50 | // of amount transfer 51 | struct money { 52 | char usernameto[50]; 53 | char userpersonfrom[50]; 54 | long int money1; 55 | }; 56 | 57 | struct userpass { 58 | char password[50]; 59 | }; 60 | 61 | // Driver Code 62 | int main() 63 | { 64 | int i, a, b, choice; 65 | int passwordlength; 66 | 67 | gotoxy(20, 3); 68 | 69 | // Creating a Main 70 | // menu for the user 71 | printf("WELCOME TO BANK ACCOUNT SYSTEM\n\n"); 72 | gotoxy(18, 5); 73 | 74 | printf("**********************************"); 75 | gotoxy(25, 7); 76 | 77 | printf("DEVELOPER-Naman kumar"); 78 | 79 | gotoxy(20, 10); 80 | printf("1.... CREATE A BANK ACCOUNT"); 81 | 82 | gotoxy(20, 12); 83 | printf("2.... ALREADY A USER? SIGN IN"); 84 | gotoxy(20, 14); 85 | printf("3.... EXIT\n\n"); 86 | 87 | printf("\n\nENTER YOUR CHOICE.."); 88 | 89 | scanf("%d", &choice); 90 | 91 | switch (choice) { 92 | case 1: 93 | system("cls"); 94 | printf("\n\n USERNAME 50 CHARACTERS MAX!!"); 95 | printf("\n\n PASSWORD 50 CHARACTERS MAX!!"); 96 | account(); 97 | break; 98 | 99 | case 2: 100 | login(); 101 | break; 102 | 103 | case 3: 104 | exit(0); 105 | break; 106 | 107 | getch(); 108 | } 109 | } 110 | 111 | // Function to create accounts 112 | // of users 113 | void account(void) 114 | { 115 | char password[20]; 116 | int passwordlength, i, seek = 0; 117 | char ch; 118 | FILE *fp, *fu; 119 | struct pass u1; 120 | struct userpass p1; 121 | 122 | struct userpass u2; 123 | 124 | // Opening file to 125 | // write data of a user 126 | fp = fopen("username.txt", "ab"); 127 | 128 | // Inputs 129 | system("cls"); 130 | printf("\n\n!!!!!CREATE ACCOUNT!!!!!"); 131 | 132 | printf("\n\nFIRST NAME.."); 133 | scanf("%s", &u1.fname); 134 | 135 | printf("\n\n\nLAST NAME.."); 136 | scanf("%s", &u1.lname); 137 | 138 | printf("\n\nFATHER's NAME.."); 139 | scanf("%s", &u1.fathname); 140 | 141 | printf("\n\nMOTHER's NAME.."); 142 | scanf("%s", &u1.mothname); 143 | 144 | printf("\n\nADDRESS.."); 145 | scanf("%s", &u1.address); 146 | 147 | printf("\n\nACCOUNT TYPE"); 148 | scanf("%s", &u1.typeaccount); 149 | 150 | printf("\n\nDATE OF BIRTH.."); 151 | printf("\nDATE-"); 152 | scanf("%d", &u1.date); 153 | printf("\nMONTH-"); 154 | scanf("%d", &u1.month); 155 | printf("\nYEAR-"); 156 | scanf("%d", &u1.year); 157 | 158 | printf("\n\nADHAR NUMBER"); 159 | scanf("%s", u1.adharnum); 160 | 161 | printf("\n\nPHONE NUMBER"); 162 | scanf("%s", u1.pnumber); 163 | 164 | printf("\n\nUSERNAME.. "); 165 | scanf("%s", &u1.username); 166 | 167 | printf("\n\nPASSWORD.."); 168 | 169 | // Taking password in the form of 170 | // stars 171 | for (i = 0; i < 50; i++) { 172 | ch = getch(); 173 | if (ch != 13) { 174 | password[i] = ch; 175 | ch = '*'; 176 | printf("%c", ch); 177 | } 178 | else 179 | break; 180 | } 181 | 182 | // Writing to the file 183 | fwrite(&u1, sizeof(u1), 184 | 1, fp); 185 | 186 | // Closing file 187 | fclose(fp); 188 | 189 | // Calling another function 190 | // after successful creation 191 | // of account 192 | accountcreated(); 193 | } 194 | 195 | // Successful account creation 196 | void accountcreated(void) 197 | { 198 | int i; 199 | char ch; 200 | system("cls"); 201 | printf( 202 | "PLEASE WAIT....\n\nYOUR DATA IS PROCESSING...."); 203 | for (i = 0; i < 200000000; i++) { 204 | i++; 205 | i--; 206 | } 207 | 208 | gotoxy(30, 10); 209 | 210 | printf("ACCOUNT CREATED SUCCESSFULLY...."); 211 | gotoxy(0, 20); 212 | 213 | printf("Press enter to login"); 214 | 215 | getch(); 216 | login(); 217 | } 218 | 219 | // Login function to check 220 | // the username of the user 221 | void login(void) 222 | { 223 | system("cls"); 224 | 225 | char username[50]; 226 | char password[50]; 227 | 228 | int i, j, k; 229 | char ch; 230 | FILE *fp, *fu; 231 | struct pass u1; 232 | struct userpass u2; 233 | 234 | // Opening file of 235 | // user data 236 | fp = fopen("username.txt", 237 | "rb"); 238 | 239 | if (fp == NULL) { 240 | printf("ERROR IN OPENING FILE"); 241 | } 242 | gotoxy(34, 2); 243 | printf(" ACCOUNT LOGIN "); 244 | gotoxy(7, 5); 245 | printf("***********************************************" 246 | "********************************"); 247 | 248 | gotoxy(35, 10); 249 | printf("==== LOG IN ===="); 250 | 251 | // Take input 252 | gotoxy(35, 12); 253 | printf("USERNAME.. "); 254 | scanf("%s", &username); 255 | 256 | gotoxy(35, 14); 257 | printf("PASSWORD.."); 258 | 259 | // Input the password 260 | for (i = 0; i < 50; i++) { 261 | ch = getch(); 262 | if (ch != 13) { 263 | password[i] = ch; 264 | ch = '*'; 265 | printf("%c", ch); 266 | } 267 | 268 | else 269 | break; 270 | } 271 | 272 | // Checking if username 273 | // exists in the file or not 274 | while (fread(&u1, sizeof(u1), 275 | 1, fp)) { 276 | if (strcmp(username, 277 | u1.username) 278 | == 0) { 279 | loginsu(); 280 | display(username); 281 | } 282 | } 283 | 284 | // Closing the file 285 | fclose(fp); 286 | } 287 | 288 | // Redirect after 289 | // successful login 290 | void loginsu(void) 291 | { 292 | int i; 293 | FILE* fp; 294 | struct pass u1; 295 | system("cls"); 296 | printf("Fetching account details.....\n"); 297 | for (i = 0; i < 20000; i++) { 298 | i++; 299 | i--; 300 | } 301 | 302 | gotoxy(30, 10); 303 | printf("LOGIN SUCCESSFUL...."); 304 | gotoxy(0, 20); 305 | printf("Press enter to continue"); 306 | 307 | getch(); 308 | } 309 | 310 | // Display function to show the 311 | // data of the user on screen 312 | void display(char username1[]) 313 | { 314 | system("cls"); 315 | FILE* fp; 316 | int choice, i; 317 | fp = fopen("username.txt", "rb"); 318 | struct pass u1; 319 | 320 | if (fp == NULL) { 321 | printf("error in opening file"); 322 | } 323 | 324 | while (fread(&u1, sizeof(u1), 325 | 1, fp)) { 326 | if (strcmp(username1, 327 | u1.username) 328 | == 0) { 329 | gotoxy(30, 1); 330 | printf("WELCOME, %s %s", 331 | u1.fname, u1.lname); 332 | gotoxy(28, 2); 333 | printf(".........................."); 334 | gotoxy(55, 6); 335 | printf("==== YOUR ACCOUNT INFO ===="); 336 | gotoxy(55, 8); 337 | printf("***************************"); 338 | gotoxy(55, 10); 339 | printf("NAME..%s %s", u1.fname, 340 | u1.lname); 341 | 342 | gotoxy(55, 12); 343 | printf("FATHER's NAME..%s %s", 344 | u1.fathname, 345 | u1.lname); 346 | 347 | gotoxy(55, 14); 348 | printf("MOTHER's NAME..%s", 349 | u1.mothname); 350 | 351 | gotoxy(55, 16); 352 | printf("ADHAR CARD NUMBER..%s", 353 | u1.adharnum); 354 | 355 | gotoxy(55, 18); 356 | printf("MOBILE NUMBER..%s", 357 | u1.pnumber); 358 | 359 | gotoxy(55, 20); 360 | printf("DATE OF BIRTH.. %d-%d-%d", 361 | u1.date, u1.month, u1.year); 362 | 363 | gotoxy(55, 22); 364 | printf("ADDRESS..%s", u1.address); 365 | 366 | gotoxy(55, 24); 367 | printf("ACCOUNT TYPE..%s", 368 | u1.typeaccount); 369 | } 370 | } 371 | 372 | fclose(fp); 373 | 374 | gotoxy(0, 6); 375 | 376 | // Menu to perform different 377 | // actions by user 378 | printf(" HOME "); 379 | gotoxy(0, 7); 380 | printf("******"); 381 | gotoxy(0, 9); 382 | printf(" 1....CHECK BALANCE"); 383 | gotoxy(0, 11); 384 | printf(" 2....TRANSFER MONEY"); 385 | gotoxy(0, 13); 386 | printf(" 3....LOG OUT\n\n"); 387 | gotoxy(0, 15); 388 | printf(" 4....EXIT\n\n"); 389 | 390 | printf(" ENTER YOUR CHOICES.."); 391 | scanf("%d", &choice); 392 | 393 | switch (choice) { 394 | case 1: 395 | checkbalance(username1); 396 | break; 397 | 398 | case 2: 399 | transfermoney(); 400 | break; 401 | 402 | case 3: 403 | logout(); 404 | login(); 405 | break; 406 | 407 | case 4: 408 | exit(0); 409 | break; 410 | } 411 | } 412 | 413 | // Function to transfer 414 | // money from one user to 415 | // another 416 | void transfermoney(void) 417 | { 418 | int i, j; 419 | FILE *fm, *fp; 420 | struct pass u1; 421 | struct money m1; 422 | char usernamet[20]; 423 | char usernamep[20]; 424 | system("cls"); 425 | 426 | // Opening file in read mode to 427 | // read user's username 428 | fp = fopen("username.txt", "rb"); 429 | 430 | // Creating a another file 431 | // to write amount along with 432 | // username to which amount 433 | // is going to be transferred 434 | fm = fopen("mon.txt", "ab"); 435 | 436 | gotoxy(33, 4); 437 | printf("---- TRANSFER MONEY ----"); 438 | gotoxy(33, 5); 439 | printf("========================"); 440 | 441 | gotoxy(33, 11); 442 | printf("FROM (your username).. "); 443 | scanf("%s", &usernamet); 444 | 445 | gotoxy(33, 13); 446 | printf(" TO (username of person).."); 447 | scanf("%s", &usernamep); 448 | 449 | // Checking for username if it 450 | // is present in file or not 451 | while (fread(&u1, sizeof(u1), 452 | 1, fp)) 453 | 454 | { 455 | if (strcmp(usernamep, 456 | u1.username) 457 | == 0) { 458 | strcpy(m1.usernameto, 459 | u1.username); 460 | strcpy(m1.userpersonfrom, 461 | usernamet); 462 | } 463 | } 464 | gotoxy(33, 16); 465 | 466 | // Taking amount input 467 | printf("ENTER THE AMOUNT TO BE TRANSFERRED.."); 468 | scanf("%d", &m1.money1); 469 | 470 | // Writing to the file 471 | fwrite(&m1, sizeof(m1), 472 | 1, fm); 473 | 474 | gotoxy(0, 26); 475 | printf( 476 | "--------------------------------------------------" 477 | "--------------------------------------------"); 478 | 479 | gotoxy(0, 28); 480 | printf( 481 | "--------------------------------------------------" 482 | "--------------------------------------------"); 483 | 484 | gotoxy(0, 29); 485 | printf("transferring amount, Please wait.."); 486 | 487 | gotoxy(10, 27); 488 | for (i = 0; i < 70; i++) { 489 | for (j = 0; j < 1200000; j++) { 490 | j++; 491 | j--; 492 | } 493 | printf("*"); 494 | } 495 | 496 | gotoxy(33, 40); 497 | printf("AMOUNT SUCCESSFULLY TRANSFERRED...."); 498 | getch(); 499 | 500 | // Close the files 501 | fclose(fp); 502 | fclose(fm); 503 | 504 | // Function to return 505 | // to the home screen 506 | display(usernamet); 507 | } 508 | 509 | // Function to check balance 510 | // in users account 511 | void checkbalance(char username2[]) 512 | { 513 | system("cls"); 514 | FILE* fm; 515 | struct money m1; 516 | char ch; 517 | int i = 1, summoney = 0; 518 | 519 | // Opening amount file record 520 | fm = fopen("mon.txt", "rb"); 521 | 522 | int k = 5, l = 10; 523 | int m = 30, n = 10; 524 | int u = 60, v = 10; 525 | 526 | gotoxy(30, 2); 527 | printf("==== BALANCE DASHBOARD ===="); 528 | gotoxy(30, 3); 529 | printf("***************************"); 530 | gotoxy(k, l); 531 | printf("S no."); 532 | gotoxy(m, n); 533 | printf("TRANSACTION ID"); 534 | gotoxy(u, v); 535 | printf("AMOUNT"); 536 | 537 | // Reading username to 538 | // fetch the correct record 539 | while (fread(&m1, sizeof(m1), 540 | 1, fm)) { 541 | if (strcmp(username2, 542 | m1.usernameto) 543 | == 0) { 544 | gotoxy(k, ++l); 545 | printf("%d", i); 546 | i++; 547 | gotoxy(m, ++n); 548 | printf("%s", m1.userpersonfrom); 549 | 550 | gotoxy(u, ++v); 551 | printf("%d", m1.money1); 552 | // Adding and 553 | // finding total money 554 | summoney = summoney + m1.money1; 555 | } 556 | } 557 | 558 | gotoxy(80, 10); 559 | printf("TOTAL AMOUNT"); 560 | 561 | gotoxy(80, 12); 562 | printf("%d", summoney); 563 | 564 | getch(); 565 | 566 | // Closing file after 567 | // reading it 568 | fclose(fm); 569 | display(username2); 570 | } 571 | 572 | // Logout function to bring 573 | // user to the login screen 574 | void logout(void) 575 | { 576 | int i, j; 577 | system("cls"); 578 | printf("please wait, logging out"); 579 | 580 | for (i = 0; i < 10; i++) { 581 | for (j = 0; j < 25000000; j++) { 582 | i++; 583 | i--; 584 | } 585 | printf("."); 586 | } 587 | 588 | gotoxy(30, 10); 589 | printf("Sign out successfully..\n"); 590 | 591 | gotoxy(0, 20); 592 | printf("press any key to continue.."); 593 | 594 | getch(); 595 | } 596 | -------------------------------------------------------------------------------- /Mini-Voting-System-master/ELECTION.H: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | struct currentValidID{ 7 | int year; 8 | char branch[6]; 9 | int totalVoters; 10 | }; 11 | typedef struct candidate{ 12 | int cid; 13 | char cname[20]; 14 | int votes; 15 | }CANDIDATE; 16 | 17 | //GLOBALS -------------------------------------------------------- 18 | struct currentValidID currentValidID; //stores current Valid user ID parameters 19 | CANDIDATE candidateArray[20]; //to store information all candidates 20 | int numberOfCandidates; //Total number of candidates standing for election 21 | char studentVotes[200]; //to store information of votes given by each student 22 | //---------------------------------------------------------------- 23 | 24 | //To extract year from userID -- For example, userID:2018btecs00064 year:2018 25 | int extractYear(char userID[15]) 26 | { 27 | int year=0; 28 | char tmp; 29 | for(int i=0;i<4;i++){ 30 | tmp=userID[i]; 31 | year=(year*10)+(tmp-48); 32 | } 33 | return year; 34 | } 35 | 36 | int extractRollNo(char userID[15]) 37 | { 38 | int rollno=0; 39 | char tmp; 40 | for(int i=9;i<14;i++){ 41 | tmp=userID[i]; 42 | rollno=(rollno*10)+(tmp-48); 43 | } 44 | return rollno; 45 | } 46 | 47 | //Will check whether the global branch code and inputed branch code is matching or not 48 | int checkBranchCode(char userID[15]) 49 | { 50 | char branchCode[6]; 51 | for(int i=4;i<9;i++){ 52 | branchCode[i-4]=userID[i]; 53 | } 54 | branchCode[5]='\0'; 55 | if(strcmp(branchCode,currentValidID.branch)==0) 56 | return 1; 57 | else 58 | return 0; 59 | } 60 | 61 | int authenticateAdmin(){ 62 | char username[15], password[6]; 63 | 64 | printf("\nEnter username: "); 65 | scanf("%s",username); 66 | if((strcmp(username,"Admin"))!=0) 67 | return 0; 68 | else 69 | { 70 | printf("Enter Password: "); 71 | int i=0; 72 | for(i=0;i<5;i++) 73 | { 74 | password[i]=getch(); 75 | printf("%c",'*'); 76 | } 77 | password[i]='\0'; 78 | if((strcmp(password,"admiN"))!=0) 79 | return 0; 80 | } 81 | return 1; 82 | } 83 | 84 | void banID(){ 85 | printf("\nCreating Banned.txt...\n"); 86 | FILE *fp=fopen("Banned.txt", "w"); 87 | if(fp==NULL){ 88 | printf("Error: Banned.txt not created.\n"); 89 | fclose(fp); 90 | return; 91 | } 92 | printf("Just Enter last roll no to ban\nPress 0 to exit... "); 93 | int input; 94 | while(1){ 95 | printf("\nEnter Number: "); 96 | scanf("%d",&input); 97 | if(input==0) 98 | break; 99 | studentVotes[input-1]='$'; 100 | fprintf(fp,"%d\n",input); 101 | } 102 | fclose(fp); 103 | printf("Created Successfully\n"); 104 | } 105 | 106 | void createCandidateFiles(){ 107 | printf("\nCreating candidate files...\n"); 108 | FILE *fp; 109 | char filename[20]; 110 | for(int i = 1;i <= numberOfCandidates; i++){ 111 | sprintf(filename,"candidate%d.txt",i); 112 | fp=fopen(filename,"w"); 113 | fprintf( 114 | fp,"0\n%s", 115 | candidateArray[i-1].cname 116 | ); 117 | fclose(fp); 118 | } 119 | printf("Created Files successfully\n"); 120 | } 121 | 122 | void deleteIllegalVote(char userID[15]) 123 | { 124 | FILE *fp,*fcp; 125 | char filename[20]; 126 | char line[20]; 127 | 128 | int location = extractRollNo(userID); 129 | sprintf(filename,"candidate%d.txt",candidateArray[studentVotes[location-1]-49].cid); 130 | candidateArray[studentVotes[location-1]-49].votes--; 131 | studentVotes[location-1]='0'; 132 | if ((fp = fopen(filename,"r")) == NULL) 133 | { 134 | printf("\nFile cannot be opened...Operation Failed"); 135 | return; 136 | } 137 | printf("\nDeleting in process...\n "); 138 | if ((fcp = fopen("tmp.txt","w")) == NULL) 139 | { 140 | printf("\nFile cannot be opened...Operation Failed"); 141 | return; 142 | } 143 | 144 | while (!feof(fp)) 145 | { 146 | fscanf(fp,"%s",line); 147 | fprintf(fcp,"%s\n",line); 148 | } 149 | fclose(fp); 150 | fclose(fcp); 151 | if ((fp = fopen(filename,"w")) == NULL) 152 | { 153 | printf("\nFile cannot be opened...Operation Failed"); 154 | return; 155 | } 156 | int numFromFile; 157 | char cnameFromFile[20]; 158 | fcp = fopen("tmp.txt","r"); 159 | fscanf(fcp,"%d",&numFromFile); 160 | fprintf(fp,"%d",numFromFile-1); 161 | fscanf(fcp,"%s",cnameFromFile); 162 | fprintf(fp,"\n%s",cnameFromFile); 163 | while(!feof(fcp)){ 164 | fscanf(fcp,"%d",&numFromFile); 165 | if(numFromFile!=location) 166 | fprintf(fp,"\n%d",numFromFile); 167 | } 168 | fclose(fp); 169 | fclose(fcp); 170 | remove("tmp.txt"); 171 | printf("\nVote deleted successfully\nPress any key to continue..."); 172 | getch(); 173 | } 174 | 175 | int getWinner(){ 176 | int maxV = -1; 177 | int winnerCid; 178 | for(int i = 0;i < numberOfCandidates; i++){ 179 | if(candidateArray[i].votes > maxV) { 180 | winnerCid = candidateArray[i].cid; 181 | maxV = candidateArray[i].votes; 182 | } 183 | else if(candidateArray[i].votes == maxV) { 184 | return -1; 185 | } 186 | } 187 | return winnerCid; 188 | } 189 | 190 | void initiateNewElection() 191 | { 192 | printf("\nNew Election Initiation:\n"); 193 | 194 | printf("\nElections for which Year: "); 195 | scanf("%d",¤tValidID.year); 196 | printf("Enter branch code:"); 197 | scanf("%s",currentValidID.branch); 198 | printf("Enter max roll no.:"); 199 | scanf("%d",¤tValidID.totalVoters); 200 | printf("Enter the no. of candidates:"); 201 | scanf("%d",&numberOfCandidates); 202 | 203 | for (int i = 0; i < currentValidID.totalVoters; i++) 204 | { 205 | studentVotes[i] = '0'; 206 | } 207 | 208 | for (int i = 0;i < numberOfCandidates; i++) 209 | { 210 | candidateArray[i].cid=i+1; 211 | printf("Enter name of candidate %d: ",i+1); 212 | scanf(" %s",candidateArray[i].cname); 213 | candidateArray[i].votes=0; 214 | } 215 | return; 216 | } 217 | 218 | void saveElectionInfoInFile(){ 219 | printf("Saving Election Info in File...\n"); 220 | FILE *fp = fopen("ElectionInfo.txt", "w"); 221 | if(fp==NULL) 222 | { 223 | printf("\nError in file creation\n"); 224 | fclose(fp); 225 | return; 226 | } 227 | fprintf( 228 | fp,"%d\n%s\n%d\n%d", 229 | currentValidID.year, 230 | currentValidID.branch, 231 | currentValidID.totalVoters, 232 | numberOfCandidates 233 | ); 234 | fclose(fp); 235 | printf("Saved Successfully : )"); 236 | } 237 | 238 | void loadElectionInfoFromFile() 239 | { 240 | FILE *f1,*f2,*f3; 241 | f1=fopen("ElectionInfo.txt","r"); 242 | if(f1==NULL) 243 | printf("Not Exist"); 244 | fscanf(f1,"%d",¤tValidID.year); 245 | fseek(f1,2,SEEK_CUR); 246 | fscanf(f1,"%s",currentValidID.branch); 247 | fseek(f1,2,SEEK_CUR); 248 | fscanf(f1,"%d",¤tValidID.totalVoters); 249 | fseek(f1,2,SEEK_CUR); 250 | fscanf(f1,"%d",&numberOfCandidates); 251 | fclose(f1); 252 | 253 | //load candidates info and student votes 254 | for (int i = 0; i < currentValidID.totalVoters; i++) 255 | { 256 | studentVotes[i] = '0'; 257 | } 258 | for(int i=1;i<=numberOfCandidates;i++) 259 | { 260 | int location; 261 | char filename[20]; 262 | sprintf(filename,"candidate%d.txt",i); 263 | f2=fopen(filename,"r+"); 264 | candidateArray[i-1].cid=i; 265 | fscanf(f2,"%d",&candidateArray[i-1].votes); 266 | fscanf(f2,"%s",candidateArray[i-1].cname); 267 | while(!feof(f2)){ 268 | fscanf(f2,"%d",&location); 269 | studentVotes[location-1] = i+48; 270 | } 271 | fclose(f2); 272 | } 273 | 274 | //load banned votes 275 | int location; 276 | f3=fopen("banned.txt","r+"); 277 | while(!feof(f3)){ 278 | fscanf(f3,"%d",&location); 279 | studentVotes[location-1] = '$'; 280 | } 281 | fclose(f3); 282 | 283 | } 284 | 285 | void adminPanel() 286 | { 287 | while(1){ 288 | 289 | if(authenticateAdmin()!=1){ 290 | printf("\n Wrong Username or Password \n"); 291 | break; 292 | } 293 | 294 | printf("\n\nLOGGED IN SUCCESSFULLY (Press Enter)"); 295 | getch(); 296 | 297 | while(1) 298 | { 299 | char inputID[15]; 300 | char input;char banInp; 301 | int WinnerCid, totalVotedNow=0; 302 | printf("\n1.New Election\n2.Continue Previous Election\n3.Delete Illegal Vote\n4.Ban User IDs\n5.Result\n6.Logout\nOption:"); 303 | scanf(" %c",&input); 304 | 305 | switch(input) 306 | { 307 | case '1': 308 | initiateNewElection(); 309 | saveElectionInfoInFile(); 310 | createCandidateFiles(); 311 | break; 312 | case '2': 313 | loadElectionInfoFromFile(); 314 | break; 315 | case '3': 316 | printf("\nEnter user ID to delete its vote: "); 317 | scanf("%s",inputID); 318 | deleteIllegalVote(inputID); 319 | break; 320 | case '4': 321 | printf("Do you want to ban particular ID's?\nPress 1 if yes or any other key to continue..."); 322 | scanf(" %c",&banInp); 323 | if(banInp=='1'){ 324 | banID(); 325 | } 326 | break; 327 | case '5': 328 | WinnerCid = getWinner(); 329 | if(WinnerCid != -1){ 330 | printf("\nWinner is %s with %d votes\n",candidateArray[WinnerCid-1].cname,candidateArray[WinnerCid-1].votes); 331 | } 332 | else{ 333 | printf("\nIts A TIE"); 334 | } 335 | printf("\nFull Result\n"); 336 | for(int i=0;i %d votes\n",candidateArray[i].cid,candidateArray[i].cname,candidateArray[i].votes); 339 | } 340 | printf("\nVoting Percentage: %d %%\n\n",(totalVotedNow*100)/currentValidID.totalVoters); 341 | break; 342 | case '6': 343 | return; 344 | default: 345 | printf("Invalid Option"); 346 | getch(); 347 | } 348 | 349 | } 350 | } 351 | 352 | }; 353 | 354 | 355 | int isValid(char userID[15]) 356 | { 357 | if(strlen(userID)!=14) 358 | return 0; 359 | 360 | int inputedYear=extractYear(userID); 361 | int inputedRollNo = extractRollNo(userID); 362 | 363 | if(inputedYear!=currentValidID.year || checkBranchCode(userID)!=1 || inputedRollNo>currentValidID.totalVoters) 364 | return 0; 365 | 366 | return 1; 367 | } 368 | 369 | int isVoted(char userID[15]) 370 | { 371 | int location=extractRollNo(userID); 372 | if(studentVotes[location-1]=='0') 373 | return 0; 374 | else 375 | return 1; 376 | } 377 | 378 | int isBanned(char userID[15]){ 379 | int location=extractRollNo(userID); 380 | if(studentVotes[location-1]=='$') 381 | return 1; 382 | else 383 | return 0; 384 | } 385 | 386 | void saveVote(char userID[15],char voteInput) 387 | { 388 | char filename[20]; 389 | sprintf(filename,"candidate%d.txt",voteInput-48); 390 | FILE *fp = fopen(filename,"r+"); 391 | int location=extractRollNo(userID); 392 | studentVotes[location-1]=voteInput; 393 | candidateArray[voteInput-49].votes++; 394 | fseek(fp, 0, SEEK_SET); 395 | fprintf(fp,"%d\n",candidateArray[voteInput-49].votes); 396 | fseek(fp, 0, SEEK_END); 397 | fprintf(fp,"\n%d",location); 398 | fclose(fp); 399 | } 400 | 401 | 402 | void studentPanel() 403 | { 404 | char userID[15]; 405 | char voteInput; 406 | while(1) 407 | { 408 | printf("\n\n To exit press 0"); 409 | printf("\n Enter user ID:"); 410 | scanf("%s",userID); 411 | if(strcmp(userID, "0")==0) 412 | return; 413 | if(isValid(userID)!=1) 414 | { 415 | printf("\n Invalid User ID(Press Enter)"); 416 | getch(); 417 | continue; 418 | } 419 | if(isBanned(userID)!=0) 420 | { 421 | printf("\nThis User ID is currently banned...\nContact Admin for the reason...(Press Enter to continue)"); 422 | getch(); 423 | continue; 424 | } 425 | if(isVoted(userID)!=0) 426 | { 427 | printf("\n Your PRN entered is already voted\n Contact Admin for furthur query"); 428 | getch(); 429 | continue; 430 | } 431 | printf("\n\n Candidates for election:"); 432 | for (int i = 0; i < numberOfCandidates; i++) 433 | { 434 | printf("\n %d. %s",i+1,candidateArray[i].cname); 435 | } 436 | printf("\n\n Your Vote(Enter Number):"); 437 | voteInput=getch(); 438 | printf("*"); 439 | if(voteInput-48 < 1 || voteInput-48 > numberOfCandidates) 440 | { 441 | printf("\nInvalid Vote\nTry Again..."); 442 | getch(); 443 | continue; 444 | } 445 | saveVote(userID,voteInput); 446 | printf("\n\nThanks for your precious vote(Press Enter)"); 447 | getch(); 448 | } 449 | }; 450 | -------------------------------------------------------------------------------- /Employee-Management-System-master/Employee Management System-github.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define Employee struct emp 7 | //sohanuzzaman_soad 8 | void add(FILE * fp); //to add to list 9 | FILE * del(FILE * fp);//to delete from list 10 | void modify(FILE * fp);//to modify a record 11 | void displayList(FILE * fp);//display whole list 12 | void searchRecord(FILE *fp);//find a particular record 13 | void printChar(char ch,int n);//printing a character ch n times 14 | void printHead(); 15 | //sohanuzzaman_soad 16 | 17 | struct emp 18 | { 19 | int id; 20 | char name[100]; 21 | char desgn[10]; 22 | float sal; 23 | char jdate[8]; 24 | char gender[10]; 25 | char branch[50]; 26 | char psaddr[200]; 27 | char prtaddr[200]; 28 | char phone[15]; 29 | char mail[20]; 30 | }; 31 | //sohanuzzaman_soad 32 | 33 | int main() 34 | { 35 | FILE * fp; 36 | Employee e; 37 | int option; 38 | char another; 39 | 40 | if((fp=fopen("employeeInfo.txt","rb+"))==NULL) //sohanuzzaman_soad 41 | { 42 | if((fp=fopen("employeeInfo.txt","wb+"))==NULL) 43 | { 44 | printf("can't open file"); 45 | return 0; 46 | } 47 | } 48 | char username[10],password[10]; //sohanuzzaman_soad 49 | printHead(); 50 | welcome(); 51 | printHead(); 52 | printf("\n\t\t\t\t Login Screen"); 53 | printf("\n\t\t\t Enter Your Credential"); 54 | printf("\n\n\n\t\tUsername: "); 55 | scanf("%s",username); 56 | printf("\n\t\tPassword: "); 57 | int i; 58 | i=0; 59 | do 60 | { 61 | password[i] = getch(); 62 | if(password[i] == 13 )//sohanuzzaman_soad 63 | { 64 | break; 65 | } 66 | else if(password[i]==8 && i>0) 67 | { 68 | printf("%c%c%c",8,32,8); 69 | i--; 70 | } 71 | else 72 | { 73 | printf("*"); 74 | i++; 75 | } 76 | }while(password[i]!=13); 77 | password[i] = '\0'; 78 | 79 | if(((strcasecmp(username,"admin"))==0)&&((strcasecmp(password,"pass")==0))) 80 | { 81 | while(1) 82 | { 83 | printHead(); 84 | printf("\n\t\t\t\tMain Menu"); 85 | printf("\n\n\n");//sohanuzzaman_soad 86 | 87 | 88 | printf("\n\n\t\t\t1. Add Employee"); 89 | printf("\n\n\t\t\t2. Delete Employee"); 90 | printf("\n\n\t\t\t3. Modify Employee"); 91 | printf("\n\n\t\t\t4. Display Employee List"); 92 | printf("\n\n\t\t\t5. Search Record"); 93 | printf("\n\n\t\t\t6. Display Basic Info"); 94 | printf("\n\n\t\t\t7. Display Basic Contact Info"); 95 | printf("\n\n\t\t\t8. List of Male Employee"); 96 | printf("\n\n\t\t\t9. List of Female Employee"); 97 | printf("\n\n\t\t\t10. List of Employee From Dhaka"); 98 | printf("\n\n\t\t\t11. List of Employee From Others District"); 99 | printf("\n\n\t\t\t12. List of Employee of Main Branch"); 100 | printf("\n\n\t\t\t13. List of Employee of Others Branch"); 101 | printf("\n\n\t\t\t0. EXIT"); 102 | 103 | printf("\n\n\t\tEnter Your Option :--> "); 104 | scanf("%d",&option); 105 | //sohanuzzaman_soad 106 | switch(option) 107 | { 108 | case 0: return 1; 109 | break; 110 | case 1: add(fp); 111 | break; 112 | case 2: fp=del(fp); 113 | break; 114 | case 3: modify(fp); 115 | break; 116 | case 4: displayList(fp); 117 | break; 118 | case 5: searchRecord(fp); 119 | break; 120 | case 6: displaybasic(fp); 121 | break;//sohanuzzaman_soad 122 | case 7: basiccontact(fp); 123 | break; 124 | case 8: maleemp(fp); 125 | break; 126 | case 9: femaleemp(fp); 127 | break; 128 | case 10: frmdhaka(fp); 129 | break; 130 | case 11: frmors(fp); 131 | break; 132 | case 12: mainbr(fp); 133 | break; 134 | case 13: otherbr(fp); 135 | break; 136 | default: printf("\n\t\tYou Pressed wrong key"); 137 | printf("\n\t\tProgram terminated"); 138 | getch(); 139 | exit(0); 140 | 141 | }//sohanuzzaman_soad 142 | } 143 | } 144 | else { 145 | printf("\n\t\tLogin Failed"); 146 | } 147 | 148 | 149 | return 1; 150 | 151 | } 152 | 153 | //====Welcome Screen===== 154 | void welcome() 155 | { 156 | printf("\n\n\n\n\n\t\t[ [ [ WELCOME TO OUR EMPLOYEE MANAGEMENT SYSTEM ] ] ]\n\n\n\n\n\n\n\t"); 157 | system("pause"); 158 | } 159 | 160 | 161 | //----printing character ch at n times ------ 162 | 163 | void printChar(char ch,int n) 164 | { 165 | while(n--)//sohanuzzaman_soad 166 | { 167 | putchar(ch); 168 | } 169 | } 170 | 171 | //-----Printing Head Line of the program ----- 172 | 173 | void printHead() 174 | { system("cls"); 175 | printf("\t"); 176 | printChar('=',65); 177 | printf("\n\t"); 178 | printChar('=',16); 179 | printf("[EMPLOYEE] [MANAGEMENT] [SYSTEM]"); 180 | printChar('=',16); 181 | printf("\n\t"); 182 | printChar('=',65); 183 | 184 | } 185 | //sohanuzzaman_soad 186 | 187 | // ==========ADDING NEW RECORD========================== 188 | 189 | void add(FILE * fp) 190 | { 191 | printHead(); 192 | 193 | printf("\n\t\t\t\Add Employee"); 194 | char another='y'; 195 | Employee e; 196 | 197 | fseek(fp,0,SEEK_END); 198 | while(another=='y'||another=='Y') 199 | { 200 | printf("\n\n\t\tEnter ID number: "); 201 | scanf("%d",&e.id); 202 | //sohanuzzaman_soad 203 | printf("\n\n\t\tEnter Full Name of Employee: "); 204 | fflush(stdin); 205 | fgets(e.name,100,stdin); //fgets takes an extra \n character as input 206 | e.name[strlen(e.name)-1]='\0'; 207 | 208 | 209 | printf("\n\n\t\tEnter Designation: "); 210 | fflush(stdin); 211 | fgets(e.desgn,10,stdin); //fgets takes an extra \n character as input 212 | e.desgn[strlen(e.desgn)-1]='\0'; 213 | 214 | 215 | printf("\n\n\t\tEnter Gender: "); 216 | fflush(stdin); 217 | fgets(e.gender,10,stdin); //fgets takes an extra \n character as input 218 | e.gender[strlen(e.gender)-1]='\0'; 219 | 220 | printf("\n\n\t\tEnter Branch: "); 221 | fflush(stdin); 222 | fgets(e.branch,50,stdin); 223 | e.branch[strlen(e.branch)-1]='\0'; 224 | 225 | 226 | printf("\n\n\t\tEnter Salary: "); 227 | scanf("%f",&e.sal); 228 | 229 | printf("\n\n\t\tEnter Present Address: "); 230 | fflush(stdin); 231 | fgets(e.psaddr,200,stdin); 232 | e.psaddr[strlen(e.psaddr)-1]='\0'; 233 | 234 | printf("\n\n\t\tEnter Permanant Address: "); 235 | fflush(stdin);//sohanuzzaman_soad 236 | fgets(e.prtaddr,200,stdin); 237 | e.prtaddr[strlen(e.prtaddr)-1]='\0'; 238 | 239 | printf("\n\n\t\tEnter Phone: "); 240 | fflush(stdin); 241 | fgets(e.phone,50,stdin); 242 | e.phone[strlen(e.phone)-1]='\0'; 243 | 244 | printf("\n\n\t\tEnter E-mail: "); 245 | fflush(stdin); 246 | fgets(e.mail,20,stdin); 247 | e.mail[strlen(e.mail)-1]='\0'; 248 | 249 | fwrite(&e,sizeof(e),1,fp); 250 | 251 | printf("\n\n\t\tWant to enter another employee info (Y/N)\t"); 252 | fflush(stdin); 253 | another=getchar(); 254 | }//sohanuzzaman_soad 255 | } 256 | 257 | 258 | //===================DELETING A RECORD FROM LIST ============ 259 | FILE * del(FILE * fp) 260 | { 261 | printHead(); 262 | printf("\n\t\t\t\Delete Employee"); 263 | Employee e; 264 | int flag=0,tempid,siz=sizeof(e); 265 | FILE *ft; 266 | 267 | if((ft=fopen("temp.txt","wb+"))==NULL)//sohanuzzaman_soad 268 | { 269 | printf("\n\n\t\t\t\\t!!! ERROR !!!\n\t\t"); 270 | system("pause"); 271 | return fp; 272 | } 273 | 274 | printf("\n\n\tEnter ID number of Employee to Delete the Record"); 275 | printf("\n\n\t\t\tID No. : "); 276 | scanf("%d",&tempid); 277 | 278 | rewind(fp); 279 | 280 | 281 | while((fread(&e,siz,1,fp))==1) 282 | {//sohanuzzaman_soad 283 | if(e.id==tempid) 284 | { flag=1; 285 | printf("\n\tRecord Deleted for"); 286 | printf("\n\n\t\t%s\n\n\t\t%s\n\n\t\t%d\n\t",e.name,e.branch,e.id); 287 | continue; 288 | } 289 | 290 | fwrite(&e,siz,1,ft); 291 | } 292 | 293 | 294 | fclose(fp); 295 | fclose(ft); 296 | 297 | remove("employeeInfo.txt"); 298 | rename("temp.txt","employeeInfo.txt"); 299 | 300 | if((fp=fopen("employeeInfo.txt","rb+"))==NULL)//sohanuzzaman_soad 301 | { 302 | printf("ERROR"); 303 | return NULL; 304 | } 305 | 306 | if(flag==0) printf("\n\n\t\t!!!! ERROR RECORD NOT FOUND \n\t"); 307 | 308 | printChar('-',65); 309 | printf("\n\t"); 310 | system("pause"); 311 | return fp; 312 | } 313 | 314 | //sohanuzzaman_soad 315 | //===========MODIFY A RECORD =========================== 316 | 317 | void modify(FILE * fp) 318 | { 319 | printHead(); 320 | printf("\n\t\t\t\Modify Employee"); 321 | Employee e; 322 | int i,flag=0,tempid,siz=sizeof(e); 323 | float sal; 324 | 325 | printf("\n\n\tEnter ID Number of Employee to Modify the Record : "); 326 | scanf("%d",&tempid); 327 | 328 | rewind(fp); 329 | 330 | while((fread(&e,siz,1,fp))==1) 331 | { 332 | if(e.id==tempid) 333 | {flag=1;//sohanuzzaman_soad 334 | break; 335 | } 336 | } 337 | 338 | if(flag==1) 339 | { 340 | fseek(fp,-siz,SEEK_CUR); 341 | printf("\n\n\t\tRecord Found"); 342 | printf("\n\n\t\tEnter New Data for the Record"); 343 | 344 | printf("\n\n\t\tEnter ID number: "); 345 | scanf("%d",&e.id); 346 | 347 | printf("\n\n\t\tEnter Full Name of Employee: "); 348 | fflush(stdin); 349 | fgets(e.name,100,stdin); //fgets takes an extra \n character as input 350 | e.name[strlen(e.name)-1]='\0';//sohanuzzaman_soad 351 | 352 | 353 | printf("\n\n\t\tEnter Designation: "); 354 | fflush(stdin); 355 | fgets(e.desgn,10,stdin); //fgets takes an extra \n character as input 356 | e.desgn[strlen(e.desgn)-1]='\0'; 357 | 358 | 359 | printf("\n\n\t\tEnter Gender: "); 360 | fflush(stdin); 361 | fgets(e.gender,10,stdin); //fgets takes an extra \n character as input 362 | e.gender[strlen(e.gender)-1]='\0'; 363 | 364 | printf("\n\n\t\tEnter Branch: "); 365 | fflush(stdin); 366 | fgets(e.branch,50,stdin);//sohanuzzaman_soad 367 | e.branch[strlen(e.branch)-1]='\0'; 368 | 369 | 370 | printf("\n\n\t\tEnter Salary: "); 371 | scanf("%f",&e.sal); 372 | 373 | printf("\n\n\t\tEnter Present Address: "); 374 | fflush(stdin); 375 | fgets(e.psaddr,200,stdin); 376 | e.psaddr[strlen(e.psaddr)-1]='\0'; 377 | 378 | printf("\n\n\t\tEnter Permanant Address: "); 379 | fflush(stdin); 380 | fgets(e.prtaddr,200,stdin);//sohanuzzaman_soad 381 | e.prtaddr[strlen(e.prtaddr)-1]='\0'; 382 | 383 | printf("\n\n\t\tEnter Phone: "); 384 | fflush(stdin); 385 | fgets(e.phone,50,stdin); 386 | e.phone[strlen(e.phone)-1]='\0'; 387 | 388 | printf("\n\n\t\tEnter E-mail: "); 389 | fflush(stdin); 390 | fgets(e.mail,20,stdin); 391 | e.mail[strlen(e.mail)-1]='\0'; 392 | 393 | fwrite(&e,sizeof(e),1,fp);//sohanuzzaman_soad 394 | } 395 | 396 | else printf("\n\n\t!!!! ERROR !!!! RECORD NOT FOUND"); 397 | 398 | printf("\n\n\t"); 399 | system("pause"); 400 | 401 | } 402 | 403 | //====================DISPLAY THE LIST ================= 404 | void displayList(FILE * fp) 405 | { printHead(); 406 | printf("\n\t\t\t\List of Employees"); 407 | Employee e; 408 | int i,siz=sizeof(e); 409 | 410 | rewind(fp); 411 | 412 | while((fread(&e,siz,1,fp))==1) 413 | { 414 | printf("\n\n\t\tID : %d",e.id);//sohanuzzaman_soad 415 | printf("\n\n\t\tNAME : %s",e.name); 416 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 417 | printf("\n\n\t\tGENDER : %s",e.gender); 418 | printf("\n\n\t\tBRANCH : %s",e.branch); 419 | printf("\n\n\t\tSALARY : %.2f",e.sal); 420 | printf("\n\n\t\tPRESENT ADDRESS : %s",e.psaddr); 421 | printf("\n\n\t\tPERMANANT ADDRESS : %s",e.prtaddr); 422 | printf("\n\n\t\tPHONE : %s",e.phone); 423 | printf("\n\n\t\tE-MAIL : %s\n\n\t",e.mail); 424 | printChar('=',65); 425 | } 426 | printf("\n\n\n\t"); 427 | printf("\n\n\t"); 428 | system("pause"); 429 | } 430 | 431 | 432 | //================SEARCH EMPLOYEE== 433 | void searchRecord(FILE *fp)//sohanuzzaman_soad 434 | {printHead(); 435 | printf("\n\t\t\t\Search Employee"); 436 | int tempid,flag,siz,i; 437 | Employee e; 438 | char another='y'; 439 | 440 | siz=sizeof(e); 441 | 442 | while(another=='y'||another=='Y') 443 | { 444 | printf("\n\n\tEnter ID Number of Employee to search the record : "); 445 | scanf("%d",&tempid); 446 | 447 | rewind(fp);//sohanuzzaman_soad 448 | 449 | while((fread(&e,siz,1,fp))==1) 450 | { 451 | if(e.id==tempid) 452 | {flag=1; 453 | break; 454 | } 455 | } 456 | 457 | if(flag==1) 458 | { 459 | printf("\n\t\tNAME : %s",e.name); 460 | printf("\n\n\t\tID : %d",e.id); 461 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 462 | printf("\n\n\t\tBRANCH : %s",e.branch);//sohanuzzaman_soad 463 | printf("\n\n\t\tSALARY: %.2f",e.sal); 464 | printf("\n\n\t\tPRESENT ADDRESS : %s",e.psaddr); 465 | printf("\n\n\t\tPERMANANT ADDRESS : %s",e.prtaddr); 466 | printf("\n\n\t\tPHONE : %s",e.phone); 467 | printf("\n\n\t\tE-MAIL : %s",e.mail); 468 | 469 | printChar('=',65); 470 | 471 | } 472 | else printf("\n\n\t\t!!!! ERROR RECORD NOT FOUND !!!!"); 473 | 474 | 475 | printf("\n\n\t\tWant to enter another search (Y/N)"); 476 | fflush(stdin);//sohanuzzaman_soad 477 | another=getchar(); 478 | } 479 | } 480 | 481 | //========================LIST OF MALE EMPLOYEE== 482 | void maleemp(FILE * fp) 483 | { 484 | printHead(); 485 | printf("\n\t\t\t\List of Male Employee"); 486 | Employee e; 487 | int i,siz=sizeof(e); 488 | 489 | rewind(fp);//sohanuzzaman_soad 490 | 491 | while((fread(&e,siz,1,fp))==1) 492 | { 493 | if((strcmp(e.gender,"Male")==0)||(strcmp(e.gender,"male")==0)) 494 | { 495 | //sohanuzzaman_soad 496 | printf("\n\n\t\tID : %d",e.id); 497 | printf("\n\n\t\tNAME : %s",e.name); 498 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 499 | printf("\n\n\t\tPHONE : %s",e.phone); 500 | printChar('-',65); 501 | } 502 | } 503 | printf("\n\n\n\t"); 504 | printChar('*',65); 505 | printf("\n\n\t"); 506 | system("pause"); 507 | } 508 | 509 | 510 | //========================LIST OF FEMALE EMPLOYEE== 511 | 512 | void femaleemp(FILE * fp) 513 | { 514 | printHead(); 515 | printf("\n\t\t\t\List of Female Employee"); 516 | Employee e; 517 | int i,siz=sizeof(e); 518 | 519 | rewind(fp); 520 | 521 | while((fread(&e,siz,1,fp))==1) 522 | { 523 | if((strcmp(e.gender,"Female")==0)||(strcmp(e.gender,"female")==0)) 524 | { 525 | printf("\n\n\t\tID : %d",e.id); 526 | printf("\n\n\t\tNAME : %s",e.name); 527 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 528 | printf("\n\n\t\tPHONE : %s",e.phone); 529 | printChar('-',65);//sohanuzzaman_soad 530 | } 531 | } 532 | printf("\n\n\n\t"); 533 | printChar('*',65); 534 | printf("\n\n\t"); 535 | system("pause"); 536 | } 537 | 538 | //========================LIST OF EMPLOYEE FROM DHAKA==== 539 | 540 | void frmdhaka(FILE * fp) 541 | { 542 | printHead(); 543 | printf("\n\t\t\t\List of Employee From Dhaka");//sohanuzzaman_soad 544 | Employee e; 545 | int i,siz=sizeof(e); 546 | 547 | rewind(fp); 548 | 549 | while((fread(&e,siz,1,fp))==1) 550 | { 551 | if((strstr(e.prtaddr,"Dhaka")==0)||(strstr(e.prtaddr,"dhaka")==0)||(strstr(e.prtaddr,"DHAKA")==0)) 552 | { 553 | printf("\n\n\t\tID : %d",e.id); 554 | printf("\n\n\t\tNAME : %s",e.name); 555 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 556 | printf("\n\n\t\tPHONE : %s",e.phone); 557 | printf("\n\n\t\tE-MAIL : %s",e.mail); 558 | printChar('=',65); 559 | } 560 | }//sohanuzzaman_soad 561 | printf("\n\n\n\t"); 562 | printf("\n\n\t"); 563 | system("pause"); 564 | } 565 | 566 | //========================LIST OF EMPLOYEE FROM ORS DIST==== 567 | 568 | void frmors(FILE * fp) 569 | { 570 | printHead(); 571 | printf("\n\t\t\t\List of Employee From Others District"); 572 | Employee e; 573 | int i,siz=sizeof(e); 574 | 575 | rewind(fp); 576 | 577 | while((fread(&e,siz,1,fp))==1) 578 | { 579 | if((strstr(e.prtaddr,"Dhaka")==1)&&(strstr(e.prtaddr,"dhaka")==1)&&(strstr(e.prtaddr,"DHAKA")==1)) 580 | { 581 | printf("\n\n\t\tID : %d",e.id); 582 | printf("\n\n\t\tNAME : %s",e.name); 583 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 584 | printf("\n\n\t\tPHONE : %s",e.phone); 585 | printf("\n\n\t\tE-MAIL : %s",e.mail); 586 | printChar('=',65); 587 | } 588 | } 589 | printf("\n\n\n\t"); 590 | printf("\n\n\t"); 591 | system("pause"); 592 | } 593 | 594 | //==============DISPLAY BASIC INFO LIST== 595 | 596 | void displaybasic(FILE * fp) 597 | { printHead();//sohanuzzaman_soad 598 | printf("\n\t\t\t\Display Basic Information"); 599 | Employee e; 600 | int i,siz=sizeof(e); 601 | 602 | rewind(fp); 603 | 604 | while((fread(&e,siz,1,fp))==1) 605 | { 606 | printf("\n\n\t\tID : %d",e.id); 607 | printf("\n\n\t\tNAME : %s",e.name); 608 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 609 | printf("\n\n\t\tGENDER : %s",e.gender); 610 | printf("\n\n\t\tBRANCH : %s",e.branch); 611 | printf("\n\n\t\tPHONE : %s",e.phone); 612 | printf("\n\n\t\tE-MAIL : %s\n\n\t",e.mail); 613 | printChar('=',65); 614 | } 615 | printf("\n\n\n\t"); 616 | printf("\n\n\t"); 617 | system("pause"); 618 | } 619 | 620 | //========BASIC CONTACT INFO LIST==== 621 | 622 | void basiccontact(FILE * fp) 623 | { printHead(); 624 | printf("\n\t\t\t\Basic Contact Information"); 625 | Employee e; 626 | int i,siz=sizeof(e); 627 | 628 | rewind(fp); 629 | 630 | while((fread(&e,siz,1,fp))==1) 631 | { 632 | printf("\n\n\t\tID : %d",e.id); 633 | printf("\n\n\t\tNAME : %s",e.name); 634 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 635 | printf("\n\n\t\tPHONE : %s",e.phone); 636 | printf("\n\n\t\tE-MAIL : %s\n\n\t",e.mail); 637 | printChar('=',65); 638 | } 639 | printf("\n\n\n\t"); 640 | printf("\n\n\t"); 641 | system("pause"); 642 | } 643 | 644 | 645 | //========================LIST OF EMPLOYEE OF MAIN BRANCH==== 646 | 647 | void mainbr(FILE * fp) 648 | { 649 | printHead(); 650 | printf("\n\t\t\t\List of Employee of Main Branch"); 651 | Employee e; 652 | int i,siz=sizeof(e); 653 | 654 | rewind(fp); 655 | 656 | while((fread(&e,siz,1,fp))==1)//sohanuzzaman_soad 657 | { 658 | if((strcmp(e.branch,"Main")==0)||(strcmp(e.prtaddr,"main")==0)||(strcmp(e.prtaddr,"MAIN")==0)) 659 | { 660 | printf("\n\n\t\tID : %d",e.id); 661 | printf("\n\n\t\tNAME : %s",e.name); 662 | printf("\n\n\t\tDESIGNATION : %s",e.desgn);//sohanuzzaman_soad 663 | printf("\n\n\t\tPHONE : %s",e.phone); 664 | printf("\n\n\t\tE-MAIL : %s\n\t",e.mail); 665 | printChar('=',65); 666 | } 667 | } 668 | printf("\n\n\n\t"); 669 | printf("\n\n\t"); 670 | system("pause"); 671 | } 672 | 673 | //========================LIST OF EMPLOYEE OF OTHRES BRANCH==== 674 | 675 | void otherbr(FILE * fp) 676 | { 677 | printHead(); 678 | printf("\n\t\t\t\List of Employee of Other Branch");//sohanuzzaman_soad 679 | Employee e; 680 | int i,siz=sizeof(e); 681 | 682 | rewind(fp); 683 | 684 | while((fread(&e,siz,1,fp))==1) 685 | { 686 | if((strcmp(e.branch,"Main")!=0)&&(strcmp(e.prtaddr,"main")!=0)&&(strcmp(e.prtaddr,"MAIN")!=0)) 687 | { 688 | printf("\n\n\t\tID : %d",e.id); 689 | printf("\n\n\t\tNAME : %s",e.name);//sohanuzzaman_soad 690 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 691 | printf("\n\n\t\tPHONE : %s",e.phone); 692 | printf("\n\n\t\tE-MAIL : %s\n\n\t",e.mail); 693 | printChar('=',65); 694 | } 695 | } 696 | printf("\n\n\n\t"); 697 | printf("\n\n\t"); 698 | system("pause"); 699 | } 700 | //sohanuzzaman_soad 701 | -------------------------------------------------------------------------------- /Library-Management-System-main/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include //contains strcmp(),strcpy(),strlen(),etc 6 | #include //contains toupper(), tolower(),etc 7 | #include //contains _dos_getdate 8 | #include 9 | //#include 10 | 11 | #define RETURNTIME 15 12 | 13 | char catagories[][15]={"Computer","Electronics","Electrical","Civil","Mechanical","Architecture"}; 14 | void returnfunc(void); 15 | void mainmenu(void); 16 | void addbooks(void); 17 | void deletebooks(void); 18 | void editbooks(void); 19 | void searchbooks(void); 20 | void issuebooks(void); 21 | void viewbooks(void); 22 | void closeapplication(void); 23 | int getdata(); 24 | int checkid(int); 25 | int t(void); 26 | //void show_mouse(void); 27 | void Password(); 28 | void issuerecord(); 29 | void loaderanim(); 30 | 31 | //list of global files that can be acceed form anywhere in program 32 | FILE *fp,*ft,*fs; 33 | 34 | 35 | COORD coord = {0, 0}; 36 | //list of global variable 37 | int s; 38 | char findbook; 39 | char password[10]={"userpass"}; 40 | 41 | void gotoxy (int x, int y) 42 | { 43 | coord.X = x; coord.Y = y; // X and Y coordinates 44 | SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); 45 | } 46 | 47 | struct meroDate 48 | { 49 | int mm,dd,yy; 50 | }; 51 | struct books 52 | { 53 | int id; 54 | char stname[20]; 55 | char name[20]; 56 | char Author[20]; 57 | int quantity; 58 | float Price; 59 | int count; 60 | int rackno; 61 | char *cat; 62 | struct meroDate issued; 63 | struct meroDate duedate; 64 | }; 65 | struct books a; 66 | int main() 67 | { 68 | Password(); 69 | getch(); 70 | return 0; 71 | 72 | } 73 | void mainmenu() 74 | { 75 | //loaderanim(); 76 | system("cls"); 77 | // textbackground(13); 78 | int i; 79 | gotoxy(20,3); 80 | printf("\xB2\xB2\xB2\xB2\xB2\xB2 LIBRARY MANAGEMENT SYSTEM \xB2\xB2\xB2\xB2\xB2\xB2"); 81 | // show_mouse(); 82 | gotoxy(20,5); 83 | printf("\xB2\xB2\xB2\xB2\ 1=> Add Books "); 84 | gotoxy(20,7); 85 | printf("\xB2\xB2\xB2\xB2\ 2=> Delete Books"); 86 | gotoxy(20,9); 87 | printf("\xB2\xB2\xB2\xB2\ 3=> Search Books"); 88 | gotoxy(20,11); 89 | printf("\xB2\xB2\xB2\xB2\ 4=> Issue Books"); 90 | gotoxy(20,13); 91 | printf("\xB2\xB2\xB2\xB2\ 5=> View Books List"); 92 | gotoxy(20,15); 93 | printf("\xB2\xB2\xB2\xB2\ 6=> Edit Book's Record"); 94 | gotoxy(20,17); 95 | printf("\xB2\xB2\xB2\xB2\ 7=> Close Application"); 96 | gotoxy(20,19); 97 | printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 98 | gotoxy(20,20); 99 | 100 | gotoxy(20,21); 101 | printf("Enter your choice:"); 102 | switch(getch()) 103 | { 104 | case '1': 105 | addbooks(); 106 | break; 107 | case '2': 108 | deletebooks(); 109 | break; 110 | case '3': 111 | searchbooks(); 112 | break; 113 | case '4': 114 | issuebooks(); 115 | break; 116 | case '5': 117 | viewbooks(); 118 | break; 119 | case '6': 120 | editbooks(); 121 | break; 122 | case '7': 123 | { 124 | system("cls"); 125 | gotoxy(16,3); 126 | printf("\tLibrary Management System"); 127 | gotoxy(16,5); 128 | printf("\tMini Project in C"); 129 | gotoxy(16,7); 130 | printf("\tis brought to you by"); 131 | gotoxy(16,9); 132 | printf("\t #The terminal Boy"); 133 | gotoxy(16,11); 134 | printf("::::::::::::::::::::::::::::"); 135 | gotoxy(16,13); 136 | printf("::::::::::::::::::::::::::::"); 137 | gotoxy(16,15); 138 | printf("Exiting in 3 second...........>"); 139 | //flushall(); 140 | Sleep(3000); 141 | exit(0); 142 | } 143 | default: 144 | { 145 | gotoxy(10,23); 146 | printf("\aWrong Entry!!Please re-entered correct option"); 147 | if(getch()) 148 | mainmenu(); 149 | } 150 | 151 | } 152 | } 153 | void addbooks(void) //funtion that add books 154 | { 155 | system("cls"); 156 | int i; 157 | gotoxy(20,3); 158 | printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2SELECT CATEGOIES\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 159 | gotoxy(20,5); 160 | printf("\xB2\xB2\xB2\xB2\ 1=> Computer"); 161 | gotoxy(20,7); 162 | printf("\xB2\xB2\xB2\xB2\ 2=> Electronics"); 163 | gotoxy(20,9); 164 | printf("\xB2\xB2\xB2\xB2\ 3=> Electrical"); 165 | gotoxy(20,11); 166 | printf("\xB2\xB2\xB2\xB2\ 4=> Civil"); 167 | gotoxy(20,13); 168 | printf("\xB2\xB2\xB2\xB2\ 5=> Mechanical"); 169 | gotoxy(20,15); 170 | printf("\xB2\xB2\xB2\xB2\ 6=> Architecture"); 171 | gotoxy(20,17); 172 | printf("\xB2\xB2\xB2\xB2\ 7=> Back to main menu"); 173 | gotoxy(20,19); 174 | printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 175 | gotoxy(20,21); 176 | printf("Enter your choice:"); 177 | scanf("%d",&s); 178 | if(s==7) 179 | 180 | mainmenu() ; 181 | system("cls"); 182 | fp=fopen("lib.dat","ab+"); 183 | if(getdata()==1) 184 | { 185 | a.cat=catagories[s-1]; 186 | fseek(fp,0,SEEK_END); 187 | fwrite(&a,sizeof(a),1,fp); 188 | fclose(fp); 189 | gotoxy(21,14); 190 | printf("The Record Is Sucessfully Saved"); 191 | gotoxy(21,15); 192 | printf("Do you want to save more?(Y / N):"); 193 | if(getch()=='n') 194 | mainmenu(); 195 | else 196 | system("cls"); 197 | addbooks(); 198 | } 199 | } 200 | void deletebooks() //function that delete items from file fp 201 | { 202 | system("cls"); 203 | int d; 204 | char another='y'; 205 | while(another=='y') //infinite loop 206 | { 207 | system("cls"); 208 | gotoxy(10,5); 209 | printf("Enter the Book ID to delete:"); 210 | scanf("%d",&d); 211 | fp=fopen("lib.dat","rb+"); 212 | rewind(fp); 213 | while(fread(&a,sizeof(a),1,fp)==1) 214 | { 215 | if(a.id==d) 216 | { 217 | 218 | gotoxy(10,7); 219 | printf("The Book Record Is Available"); 220 | gotoxy(10,8); 221 | printf("Book name is %s",a.name); 222 | gotoxy(10,9); 223 | printf("Rack No. is %d",a.rackno); 224 | findbook='t'; 225 | } 226 | } 227 | if(findbook!='t') 228 | { 229 | gotoxy(10,10); 230 | printf("No record is found modify the search"); 231 | if(getch()) 232 | mainmenu(); 233 | } 234 | if(findbook=='t' ) 235 | { 236 | gotoxy(10,9); 237 | printf("Do you want to delete it?(Y/N):"); 238 | if(getch()=='y') 239 | { 240 | ft=fopen("test.dat","wb+"); //temporary file for delete 241 | rewind(fp); 242 | while(fread(&a,sizeof(a),1,fp)==1) 243 | { 244 | if(a.id!=d) 245 | { 246 | fseek(ft,0,SEEK_CUR); 247 | fwrite(&a,sizeof(a),1,ft); //write all in tempory file except that 248 | } //we want to delete 249 | } 250 | fclose(ft); 251 | fclose(fp); 252 | remove("lib.dat"); 253 | rename("test.dat","lib.dat"); //copy all item from temporary file to fp except that 254 | fp=fopen("lib.dat","rb+"); //we want to delete 255 | if(findbook=='t') 256 | { 257 | gotoxy(10,10); 258 | printf("The Record Is Sucessfully Deleted"); 259 | gotoxy(10,11); 260 | printf("Delete another record?(Y/N)"); 261 | } 262 | } 263 | else 264 | mainmenu(); 265 | fflush(stdin); 266 | another=getch(); 267 | } 268 | } 269 | gotoxy(10,15); 270 | mainmenu(); 271 | } 272 | void searchbooks() 273 | { 274 | system("cls"); 275 | int d; 276 | printf(":::::::::::::::::::::::::::::Search Books:::::::::::::::::::::::::::::"); 277 | gotoxy(20,3); 278 | printf("\xB2\xB2\xB2\xB2\ 1=> Search By ID"); 279 | gotoxy(20,5); 280 | printf("\xB2\xB2\xB2\xB2\ 2=> Search By Name"); 281 | gotoxy( 20,9); 282 | printf("Enter Your Choice"); 283 | fp=fopen("lib.dat","rb+"); //open file for reading propose 284 | rewind(fp); //move pointer at the begining of file 285 | switch(getch()) 286 | { 287 | case '1': 288 | { 289 | system("cls"); 290 | gotoxy(25,4); 291 | printf("::::Search Books By Id::::"); 292 | gotoxy(20,6); 293 | printf("Enter the book id:"); 294 | scanf("%d",&d); 295 | gotoxy(20,8); 296 | printf("Searching....."); 297 | while(fread(&a,sizeof(a),1,fp)==1) 298 | { 299 | if(a.id==d) 300 | { 301 | Sleep(2); 302 | gotoxy(20,7); 303 | printf("The Book Is Available"); 304 | gotoxy(20,8); 305 | printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 306 | gotoxy(20,9); 307 | printf("\xB2 ID:%d",a.id);gotoxy(47,9);printf("\xB2"); 308 | gotoxy(20,10); 309 | printf("\xB2 Name:%s",a.name);gotoxy(47,10);printf("\xB2"); 310 | gotoxy(20,11); 311 | printf("\xB2 Author:%s ",a.Author);gotoxy(47,11);printf("\xB2"); 312 | gotoxy(20,12); 313 | printf("\xB2 Quantity:%d ",a.quantity);gotoxy(47,12);printf("\xB2"); gotoxy(47,11);printf("\xB2"); 314 | gotoxy(20,13); 315 | printf("\xB2 Price:Rs.%.2f",a.Price);gotoxy(47,13);printf("\xB2"); 316 | gotoxy(20,14); 317 | printf("\xB2 Rack No:%d ",a.rackno);gotoxy(47,14);printf("\xB2"); 318 | gotoxy(20,15); 319 | printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 320 | findbook='t'; 321 | } 322 | 323 | } 324 | if(findbook!='t') //checks whether conditiion enters inside loop or not 325 | { 326 | gotoxy(20,8); 327 | printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 328 | gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2"); 329 | gotoxy(20,10); 330 | printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 331 | gotoxy(22,9);printf("\aNo Record Found"); 332 | } 333 | gotoxy(20,17); 334 | printf("Try another search?(Y/N)"); 335 | if(getch()=='y') 336 | searchbooks(); 337 | else 338 | mainmenu(); 339 | break; 340 | } 341 | case '2': 342 | { 343 | char s[15]; 344 | system("cls"); 345 | gotoxy(25,4); 346 | printf("::::Search Books By Name::::"); 347 | gotoxy(20,5); 348 | printf("Enter Book Name:"); 349 | scanf("%s",s); 350 | int d=0; 351 | while(fread(&a,sizeof(a),1,fp)==1) 352 | { 353 | if(strcmp(a.name,(s))==0) //checks whether a.name is equal to s or not 354 | { 355 | gotoxy(20,7); 356 | printf("The Book Is Available"); 357 | gotoxy(20,8); 358 | printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 359 | gotoxy(20,9); 360 | printf("\xB2 ID:%d",a.id);gotoxy(47,9);printf("\xB2"); 361 | gotoxy(20,10); 362 | printf("\xB2 Name:%s",a.name);gotoxy(47,10);printf("\xB2"); 363 | gotoxy(20,11); 364 | printf("\xB2 Author:%s",a.Author);gotoxy(47,11);printf("\xB2"); 365 | gotoxy(20,12); 366 | printf("\xB2 Qantity:%d",a.quantity);gotoxy(47,12);printf("\xB2"); 367 | gotoxy(20,13); 368 | printf("\xB2 Price:Rs.%.2f",a.Price);gotoxy(47,13);printf("\xB2"); 369 | gotoxy(20,14); 370 | printf("\xB2 Rack No:%d ",a.rackno);gotoxy(47,14);printf("\xB2"); 371 | gotoxy(20,15); 372 | printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 373 | d++; 374 | } 375 | 376 | } 377 | if(d==0) 378 | { 379 | gotoxy(20,8); 380 | printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 381 | gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2"); 382 | gotoxy(20,10); 383 | printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 384 | gotoxy(22,9);printf("\aNo Record Found"); 385 | } 386 | gotoxy(20,17); 387 | printf("Try another search?(Y/N)"); 388 | if(getch()=='y') 389 | searchbooks(); 390 | else 391 | mainmenu(); 392 | break; 393 | } 394 | default : 395 | getch(); 396 | searchbooks(); 397 | } 398 | fclose(fp); 399 | } 400 | void issuebooks(void) //function that issue books from library 401 | { 402 | int t; 403 | 404 | system("cls"); 405 | printf(":::::::::::::::::::::::::::::::ISSUE SECTION::::::::::::::::::::::::::::::::"); 406 | gotoxy(20,5); 407 | printf("\xB2\xB2\xB2\xB2\ 1=> Issue a Book"); 408 | gotoxy(20,7); 409 | printf("\xB2\xB2\xB2\xB2\ 2=> View Issued Book"); 410 | gotoxy(20,9); 411 | printf("\xB2\xB2\xB2\xB2\ 3=> Search Issued Book"); 412 | gotoxy(20,11); 413 | printf("\xB2\xB2\xB2\xB2\ 4=> Remove Issued Book"); 414 | gotoxy(20,14); 415 | printf("Enter a Choice:"); 416 | switch(getch()) 417 | { 418 | case '1': //issue book 419 | { 420 | system("cls"); 421 | int c=0; 422 | char another='y'; 423 | while(another=='y') 424 | { 425 | system("cls"); 426 | gotoxy(15,4); 427 | printf(":::Issue Book section:::"); 428 | gotoxy(10,6); 429 | printf("Enter the Book Id:"); 430 | scanf("%d",&t); 431 | fp=fopen("lib.dat","rb"); 432 | fs=fopen("Issue.dat","ab+"); 433 | if(checkid(t)==0) //issues those which are present in library 434 | { 435 | gotoxy(10,8); 436 | printf("The Book Record Is Available!"); 437 | gotoxy(10,9); 438 | printf("There are %d unissued books in library ",a.quantity); 439 | gotoxy(10,10); 440 | printf("The name of book is %s",a.name); 441 | gotoxy(10,11); 442 | printf("Enter student name:"); 443 | scanf("%s",a.stname); 444 | //struct dosdate_t d; //for current date 445 | //_dos_getdate(&d); 446 | //a.issued.dd=d.day; 447 | //a.issued.mm=d.month; 448 | //a.issued.yy=d.year; 449 | gotoxy(10,12); 450 | printf("Issued date=%d-%d-%d",a.issued.dd,a.issued.mm,a.issued.yy); 451 | gotoxy(10,13); 452 | printf("The BOOK of ID %d is issued",a.id); 453 | a.duedate.dd=a.issued.dd+RETURNTIME; //for return date 454 | a.duedate.mm=a.issued.mm; 455 | a.duedate.yy=a.issued.yy; 456 | if(a.duedate.dd>30) 457 | { 458 | a.duedate.mm+=a.duedate.dd/30; 459 | a.duedate.dd-=30; 460 | 461 | } 462 | if(a.duedate.mm>12) 463 | { 464 | a.duedate.yy+=a.duedate.mm/12; 465 | a.duedate.mm-=12; 466 | 467 | } 468 | gotoxy(10,14); 469 | printf("To be return:%d-%d-%d",a.duedate.dd,a.duedate.mm,a.duedate.yy); 470 | fseek(fs,sizeof(a),SEEK_END); 471 | fwrite(&a,sizeof(a),1,fs); 472 | fclose(fs); 473 | c=1; 474 | } 475 | if(c==0) 476 | { 477 | gotoxy(10,11); 478 | printf("No record found"); 479 | } 480 | gotoxy(10,15); 481 | printf("Issue any more(Y/N):"); 482 | fflush(stdin); 483 | another=getche(); 484 | fclose(fp); 485 | } 486 | 487 | break; 488 | } 489 | case '2': //show issued book list 490 | { 491 | system("cls"); 492 | int j=4; 493 | printf("::::::::::::::::::::::::::::::Issued Book List:::::::::::::::::::::::::::::::\n"); 494 | gotoxy(2,2); 495 | printf("STUDENT NAME CATEGORY ID BOOK NAME ISSUED DATE RETURN DATE"); 496 | fs=fopen("Issue.dat","rb"); 497 | while(fread(&a,sizeof(a),1,fs)==1) 498 | { 499 | 500 | gotoxy(2,j); 501 | printf("%s",a.stname); 502 | gotoxy(18,j); 503 | printf("%s",a.cat); 504 | gotoxy(30,j); 505 | printf("%d",a.id); 506 | gotoxy(36,j); 507 | printf("%s",a.name); 508 | gotoxy(51,j); 509 | printf("%d-%d-%d",a.issued.dd,a.issued.mm,a.issued.yy ); 510 | gotoxy(65,j); 511 | printf("%d-%d-%d",a.duedate.dd,a.duedate.mm,a.duedate.yy); 512 | //struct dosdate_t d; 513 | //_dos_getdate(&d); 514 | gotoxy(50,25); 515 | // printf("Current date=%d-%d-%d",d.day,d.month,d.year); 516 | j++; 517 | 518 | } 519 | fclose(fs); 520 | gotoxy(1,25); 521 | returnfunc(); 522 | } 523 | break; 524 | case '3': //search issued books by id 525 | { 526 | system("cls"); 527 | gotoxy(10,6); 528 | printf("Enter Book ID:"); 529 | int p,c=0; 530 | char another='y'; 531 | while(another=='y') 532 | { 533 | 534 | scanf("%d",&p); 535 | fs=fopen("Issue.dat","rb"); 536 | while(fread(&a,sizeof(a),1,fs)==1) 537 | { 538 | if(a.id==p) 539 | { 540 | issuerecord(); 541 | gotoxy(10,12); 542 | printf("Press any key......."); 543 | getch(); 544 | issuerecord(); 545 | c=1; 546 | } 547 | 548 | } 549 | fflush(stdin); 550 | fclose(fs); 551 | if(c==0) 552 | { 553 | gotoxy(10,8); 554 | printf("No Record Found"); 555 | } 556 | gotoxy(10,13); 557 | printf("Try Another Search?(Y/N)"); 558 | another=getch(); 559 | } 560 | } 561 | break; 562 | case '4': //remove issued books from list 563 | { 564 | system("cls"); 565 | int b; 566 | FILE *fg; //declaration of temporary file for delete 567 | char another='y'; 568 | while(another=='y') 569 | { 570 | gotoxy(10,5); 571 | printf("Enter book id to remove:"); 572 | scanf("%d",&b); 573 | fs=fopen("Issue.dat","rb+"); 574 | while(fread(&a,sizeof(a),1,fs)==1) 575 | { 576 | if(a.id==b) 577 | { 578 | issuerecord(); 579 | findbook='t'; 580 | } 581 | if(findbook=='t') 582 | { 583 | gotoxy(10,12); 584 | printf("Do You Want to Remove it?(Y/N)"); 585 | if(getch()=='y') 586 | { 587 | fg=fopen("record.dat","wb+"); 588 | rewind(fs); 589 | while(fread(&a,sizeof(a),1,fs)==1) 590 | { 591 | if(a.id!=b) 592 | { 593 | fseek(fs,0,SEEK_CUR); 594 | fwrite(&a,sizeof(a),1,fg); 595 | } 596 | } 597 | fclose(fs); 598 | fclose(fg); 599 | remove("Issue.dat"); 600 | rename("record.dat","Issue.dat"); 601 | gotoxy(10,14); 602 | printf("The issued book is removed from list"); 603 | 604 | } 605 | 606 | } 607 | if(findbook!='t') 608 | { 609 | gotoxy(10,15); 610 | printf("No Record Found"); 611 | } 612 | } 613 | gotoxy(10,16); 614 | printf("Delete any more?(Y/N)"); 615 | another=getch(); 616 | } 617 | } 618 | default: 619 | gotoxy(10,18); 620 | printf("\aWrong Entry!!"); 621 | getch(); 622 | issuebooks(); 623 | break; 624 | } 625 | gotoxy(1,30); 626 | returnfunc(); 627 | } 628 | void viewbooks(void) //show the list of book persists in library 629 | { 630 | int i=0,j; 631 | system("cls"); 632 | gotoxy(1,1); 633 | printf("::::::::::::::::::::::::::::::::Book List:::::::::::::::::::::::::::::::::"); 634 | gotoxy(2,2); 635 | printf(" CATEGORY ID BOOK NAME AUTHOR QTY PRICE RackNo "); 636 | j=4; 637 | fp=fopen("lib.dat","rb"); 638 | while(fread(&a,sizeof(a),1,fp)==1) 639 | { 640 | gotoxy(3,j); 641 | printf("%s",a.cat); 642 | gotoxy(16,j); 643 | printf("%d",a.id); 644 | gotoxy(22,j); 645 | printf("%s",a.name); 646 | gotoxy(36,j); 647 | printf("%s",a.Author); 648 | gotoxy(50,j); 649 | printf("%d",a.quantity); 650 | gotoxy(57,j); 651 | printf("%.2f",a.Price); 652 | gotoxy(69,j); 653 | printf("%d",a.rackno); 654 | printf("\n\n"); 655 | j++; 656 | i=i+a.quantity; 657 | } 658 | gotoxy(3,25); 659 | printf("Total Books =%d",i); 660 | fclose(fp); 661 | gotoxy(35,25); 662 | returnfunc(); 663 | } 664 | void editbooks(void) //edit information about book 665 | { 666 | system("cls"); 667 | int c=0; 668 | int d,e; 669 | gotoxy(20,4); 670 | printf("****Edit Books Section****"); 671 | char another='y'; 672 | while(another=='y') 673 | { 674 | system("cls"); 675 | gotoxy(15,6); 676 | printf("Enter Book Id to be edited:"); 677 | scanf("%d",&d); 678 | fp=fopen("lib.dat","rb+"); 679 | while(fread(&a,sizeof(a),1,fp)==1) 680 | { 681 | if(checkid(d)==0) 682 | { 683 | gotoxy(15,7); 684 | printf("The Book Is Available"); 685 | gotoxy(15,8); 686 | printf("The Book ID:%d",a.id); 687 | gotoxy(15,9); 688 | printf("Enter New Name:");scanf("%s",a.name); 689 | gotoxy(15,10); 690 | printf("Enter New Author:");scanf("%s",a.Author); 691 | gotoxy(15,11); 692 | printf("Add New Quantity:");scanf("%d",&a.quantity); 693 | gotoxy(15,12); 694 | printf("Enter New Price:");scanf("%f",&a.Price); 695 | gotoxy(15,13); 696 | printf("Enter New Rackno:");scanf("%d",&a.rackno); 697 | gotoxy(15,14); 698 | printf("The record is modified"); 699 | fseek(fp,ftell(fp)-sizeof(a),0); 700 | fwrite(&a,sizeof(a),1,fp); 701 | fclose(fp); 702 | c=1; 703 | } 704 | if(c==0) 705 | { 706 | gotoxy(15,9); 707 | printf("No record found"); 708 | } 709 | } 710 | gotoxy(15,16); 711 | printf("Modify another Record?(Y/N)"); 712 | fflush(stdin); 713 | another=getch() ; 714 | } 715 | returnfunc(); 716 | } 717 | void returnfunc(void) 718 | { 719 | { 720 | printf(" Press ENTER to return to main menu"); 721 | } 722 | a: 723 | if(getch()==13) //allow only use of enter 724 | mainmenu(); 725 | else 726 | goto a; 727 | } 728 | int getdata() 729 | { 730 | int t; 731 | gotoxy(20,3);printf("Enter the Information Below"); 732 | gotoxy(20,4);printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 733 | gotoxy(20,5); 734 | printf("\xB2");gotoxy(46,5);printf("\xB2"); 735 | gotoxy(20,6); 736 | printf("\xB2");gotoxy(46,6);printf("\xB2"); 737 | gotoxy(20,7); 738 | printf("\xB2");gotoxy(46,7);printf("\xB2"); 739 | gotoxy(20,8); 740 | printf("\xB2");gotoxy(46,8);printf("\xB2"); 741 | gotoxy(20,9); 742 | printf("\xB2");gotoxy(46,9);printf("\xB2"); 743 | gotoxy(20,10); 744 | printf("\xB2");gotoxy(46,10);printf("\xB2"); 745 | gotoxy(20,11); 746 | printf("\xB2");gotoxy(46,11);printf("\xB2"); 747 | gotoxy(20,12); 748 | printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); 749 | gotoxy(21,5); 750 | printf("Category:"); 751 | gotoxy(31,5); 752 | printf("%s",catagories[s-1]); 753 | gotoxy(21,6); 754 | printf("Book ID:\t"); 755 | gotoxy(30,6); 756 | scanf("%d",&t); 757 | if(checkid(t) == 0) 758 | { 759 | gotoxy(21,13); 760 | printf("\aThe book id already exists\a"); 761 | getch(); 762 | mainmenu(); 763 | return 0; 764 | } 765 | a.id=t; 766 | gotoxy(21,7); 767 | printf("Book Name:");gotoxy(33,7); 768 | scanf("%s",a.name); 769 | gotoxy(21,8); 770 | printf("Author:");gotoxy(30,8); 771 | scanf("%s",a.Author); 772 | gotoxy(21,9); 773 | printf("Quantity:");gotoxy(31,9); 774 | scanf("%d",&a.quantity); 775 | gotoxy(21,10); 776 | printf("Price:");gotoxy(28,10); 777 | scanf("%f",&a.Price); 778 | gotoxy(21,11); 779 | printf("Rack No:");gotoxy(30,11); 780 | scanf("%d",&a.rackno); 781 | return 1; 782 | } 783 | int checkid(int t) //check whether the book is exist in library or not 784 | { 785 | rewind(fp); 786 | while(fread(&a,sizeof(a),1,fp)==1) 787 | if(a.id==t) 788 | return 0; //returns 0 if book exits 789 | return 1; //return 1 if it not 790 | } 791 | 792 | /*void show_mouse(void) //show inactive mouse pointer in programme 793 | { 794 | union REGS in,out; 795 | in.x.ax = 0x1; 796 | int86(0x33,&in,&out); 797 | }*/ 798 | void Password(void) //for password option 799 | { 800 | 801 | system("cls"); 802 | char d[25]="Enter The Password"; 803 | char ch,pass[10]; 804 | int i=0,j; 805 | //textbackground(WHITE); 806 | //textcolor(RED); 807 | gotoxy(10,4); 808 | for(j=0;j<20;j++) 809 | { 810 | Sleep(50); 811 | printf(":"); 812 | } 813 | for(j=0;j<20;j++) 814 | { 815 | Sleep(50); 816 | printf("%c",d[j]); 817 | } 818 | for(j=0;j<20;j++) 819 | { 820 | Sleep(50); 821 | printf(":"); 822 | } 823 | gotoxy(10,10); 824 | gotoxy(15,7); 825 | printf("Enter Password:"); 826 | 827 | while(ch!=13) 828 | { 829 | ch=getch(); 830 | 831 | if(ch!=13 && ch!=8){ 832 | putch('*'); 833 | pass[i] = ch; 834 | i++; 835 | } 836 | } 837 | pass[i] = '\0'; 838 | if(strcmp(pass,password)==0) 839 | { 840 | 841 | gotoxy(15,9); 842 | //textcolor(BLINK); 843 | printf("Now You Are Logged In!"); 844 | gotoxy(17,10); 845 | printf("\n\xB2\xB2\xB2\xB2\Press any key to countinue..."); 846 | getch(); 847 | mainmenu(); 848 | } 849 | else 850 | { 851 | gotoxy(15,16); 852 | printf("\aWarning!! Incorrect Password"); 853 | getch(); 854 | Password(); 855 | } 856 | } 857 | void issuerecord() //display issued book's information 858 | { 859 | system("cls"); 860 | gotoxy(10,8); 861 | printf("The Book has taken by Mr. %s",a.stname); 862 | gotoxy(10,9); 863 | printf("Issued Date:%d-%d-%d",a.issued.dd,a.issued.mm,a.issued.yy); 864 | gotoxy(10,10); 865 | printf("Returning Date:%d-%d-%d",a.duedate.dd,a.duedate.mm,a.duedate.yy); 866 | } 867 | /*void loaderanim() 868 | { 869 | int loader; 870 | system("cls"); 871 | gotoxy(20,10); 872 | printf("LOADING........"); 873 | printf("\n\n"); 874 | gotoxy(22,11); 875 | for(loader=1;loader<20;loader++) 876 | { 877 | Sleep(100);printf("%c",219);} 878 | }*/ 879 | //End of program 880 | -------------------------------------------------------------------------------- /Cafeteria-System-C/cafeteria_management.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /****************************************************************************** 6 | * Data Structures * 7 | ******************************************************************************/ 8 | 9 | struct FoodItem 10 | { 11 | char name[100]; 12 | float price; 13 | int quantity; 14 | struct FoodItem* next; 15 | }; 16 | 17 | struct OrderItem 18 | { 19 | char name[100]; 20 | char customerName[100]; 21 | float price; 22 | int quantity; 23 | struct OrderItem* next; 24 | }; 25 | 26 | struct OrderQueueNode 27 | { 28 | struct OrderItem* data; 29 | struct OrderQueueNode* next; 30 | }; 31 | 32 | struct StackNode 33 | { 34 | int tableNumber; 35 | char customerName[100]; 36 | struct OrderItem* orderInfo; 37 | struct StackNode* next; 38 | }; 39 | 40 | struct User 41 | { 42 | char username[20]; 43 | char password[20]; 44 | }; 45 | 46 | /****************************************************************************** 47 | * Global Variables * 48 | ******************************************************************************/ 49 | 50 | 51 | struct User admin = {"admin", "123"}; 52 | struct OrderQueueNode *front = NULL; 53 | struct OrderQueueNode *rear= NULL; 54 | 55 | /****************************************************************************** 56 | * Authentication check * 57 | ******************************************************************************/ 58 | 59 | /** 60 | * @brief Authenticates a user based on the provided username and password. 61 | * 62 | * @param currentUser Pointer to a User struct containing the current user's credentials. 63 | * @return 1 if authentication is successful, 0 otherwise. 64 | */ 65 | 66 | int authenticate(struct User* currentUser) 67 | { 68 | char username[20]; 69 | char password[20]; 70 | printf("Enter username: "); 71 | scanf("%s", username); 72 | printf("Enter password: "); 73 | scanf("%s", password); 74 | if (strcmp(currentUser->username, username) == 0 && strcmp(currentUser->password, password) == 0) 75 | { 76 | return 1; 77 | } 78 | else 79 | { 80 | printf("Authentication failed. Invalid username or password.\n"); 81 | return 0; 82 | } 83 | } 84 | 85 | /****************************************************************************** 86 | * Food Create,Edit,Delete,Display * 87 | ******************************************************************************/ 88 | 89 | /** 90 | * @brief Creates a new FoodItem node with the given parameters. 91 | * 92 | * @param name Name of the food item. 93 | * @param price Price of the food item. 94 | * @param quantity Quantity of the food item in stock. 95 | * @return Pointer to the newly created FoodItem node. 96 | */ 97 | 98 | struct FoodItem* createFoodItemNode(char name[], float price, int quantity) 99 | { 100 | 101 | 102 | 103 | struct FoodItem* newItem = (struct FoodItem*)malloc(sizeof(struct FoodItem)); 104 | if (newItem != NULL) 105 | { 106 | strcpy(newItem->name, name); 107 | newItem->price = price; 108 | newItem->quantity = quantity; 109 | newItem->next = NULL; 110 | } 111 | return newItem; 112 | } 113 | 114 | /** 115 | * @brief Adds a new food item to the menu. 116 | * 117 | * @param head Pointer to the head of the FoodItem linked list. 118 | * @param name Name of the food item. 119 | * @param price Price of the food item. 120 | * @param quantity Quantity of the food item in stock. 121 | */ 122 | 123 | void addFoodItem(struct FoodItem** head, char name[], float price, int quantity) 124 | { 125 | struct FoodItem* newItem = createFoodItemNode(name, price, quantity); 126 | newItem->next = *head; 127 | *head = newItem; 128 | printf("Food item added successfully!\n"); 129 | } 130 | 131 | /** 132 | * @brief Edits the details of a food item in the menu. 133 | * 134 | * @param head Pointer to the head of the FoodItem linked list. 135 | * @param oldName Name of the food item to be edited. 136 | */ 137 | void editFoodItem(struct FoodItem** head, char oldName[]) 138 | { 139 | struct FoodItem* current = *head; 140 | while (current != NULL) 141 | { 142 | if (strcmp(current->name, oldName) == 0) 143 | { 144 | printf("Enter the new name for %s: ", oldName); 145 | scanf("%s", current->name); 146 | printf("Enter the new quantity for %s: ", current->name); 147 | scanf("%d", ¤t->quantity); 148 | printf("Food item edited successfully!\n"); 149 | return; 150 | } 151 | current = current->next; 152 | } 153 | printf("Food item not found!\n"); 154 | } 155 | /** 156 | * @brief Deletes a food item from the menu based on its name. 157 | * 158 | * @param head Pointer to the head of the FoodItem linked list. 159 | * @param name Name of the food item to be deleted. 160 | */ 161 | 162 | void deleteFoodItem(struct FoodItem** head, char name[]) 163 | { 164 | struct FoodItem* current = *head; 165 | struct FoodItem* prev = NULL; 166 | while (current != NULL) 167 | { 168 | if (strcmp(current->name, name) == 0) 169 | { 170 | if (prev == NULL) 171 | { 172 | *head = current->next; 173 | } 174 | else 175 | { 176 | prev->next = current->next; 177 | } 178 | free(current); 179 | printf("Food item deleted successfully!\n"); 180 | return; 181 | } 182 | prev = current; 183 | current = current->next; 184 | } 185 | printf("Food item not found!\n"); 186 | } 187 | 188 | /** 189 | * @brief Displays the current menu with item details. 190 | * 191 | * @param head Pointer to the head of the FoodItem linked list. 192 | */ 193 | void displayMenu(struct FoodItem* head) 194 | { 195 | struct FoodItem* current = head; 196 | 197 | if (current != NULL) 198 | { 199 | printf("|--------|----------------------|------------|-----------|\n"); 200 | printf("| %-6s | %-20s | %-10s | %-9s |\n", "No.", "Name", "Price ($)", "Quantity"); 201 | printf("|--------|----------------------|------------|-----------|\n"); 202 | } 203 | else 204 | { 205 | printf("No item available\n\n"); 206 | return; 207 | } 208 | 209 | int itemNumber = 1; 210 | while (current != NULL) 211 | { 212 | printf("| %-6d | %-20s | %-10.2f | %-9d |\n", itemNumber, current->name, current->price, current->quantity); 213 | current = current->next; 214 | itemNumber++; 215 | } 216 | printf("|--------|----------------------|------------|-----------|\n"); 217 | } 218 | 219 | /****************************************************************************** 220 | * Order Create,summary * 221 | ******************************************************************************/ 222 | 223 | 224 | /** 225 | * @brief Creates a new OrderItem node with the given parameters. 226 | * 227 | * @param name Name of the ordered item. 228 | * @param price Price of the ordered item. 229 | * @param quantity Quantity of the ordered item. 230 | * @param customerName Name of the customer placing the order. 231 | * @return Pointer to the newly created OrderItem node. 232 | */ 233 | struct OrderItem* createOrderItemNode(char name[], float pricePerUnit, int quantity, char customerName[]) 234 | { 235 | struct OrderItem* newItem = (struct OrderItem*)malloc(sizeof(struct OrderItem)); 236 | if (newItem != NULL) 237 | { 238 | strcpy(newItem->name, name); 239 | strcpy(newItem->customerName, customerName); 240 | newItem->price = pricePerUnit * quantity; // Use price * quantity 241 | newItem->quantity = quantity; 242 | newItem->next = NULL; 243 | } 244 | return newItem; 245 | } 246 | /** 247 | * @brief Places an order for a specified quantity of a food item. 248 | * 249 | * @param menu Pointer to the head of the FoodItem linked list representing the menu. 250 | * @param order Pointer to the head of the OrderItem linked list representing orders. 251 | * @param name Name of the food item to be ordered. 252 | * @param quantity Quantity of the food item to be ordered. 253 | * @param customerName Name of the customer placing the order. 254 | * @return 1 if the order is successfully placed, 0 otherwise. 255 | */ 256 | int placeOrder(struct FoodItem** menu, struct OrderItem** order, const char name[], int quantity, char customerName[]) 257 | { 258 | struct FoodItem* current = *menu; 259 | while (current != NULL) 260 | { 261 | if (strcmp(current->name, name) == 0) 262 | { 263 | if (current->quantity >= quantity) 264 | { 265 | // Add the item to the order list 266 | struct OrderItem* orderItem = createOrderItemNode(name, current->price, quantity, customerName); 267 | orderItem->next = *order; 268 | *order = orderItem; 269 | 270 | // Update the quantity in the menu 271 | current->quantity -= quantity; 272 | 273 | printf("Order placed successfully for %s!\n", customerName); 274 | return 1; 275 | } 276 | else 277 | { 278 | printf("Insufficient quantity in stock!\n"); 279 | return 0; 280 | } 281 | } 282 | current = current->next; 283 | } 284 | printf("Food item not found!\n"); 285 | return 0; 286 | } 287 | /** 288 | * @brief Displays a summary of the orders, including customer names, item names, prices, and quantities. 289 | * 290 | * @param order Pointer to the head of the OrderItem linked list representing orders. 291 | */ 292 | void displayOrderSummary(struct OrderItem* order) 293 | { 294 | printf("======================================================================================\n"); 295 | printf("| O r d e r S u m m a r y |\n"); 296 | printf("======================================================================================\n"); 297 | 298 | if (order == NULL) 299 | { 300 | printf("| No Order items found! |\n"); 301 | } 302 | else 303 | { 304 | printf("| %-23s | %-32s | %-10s | %-8s |\n", "Customer Name", "Item Name", "Price ($)", "Quantity"); 305 | printf("------------------------------------------------------------------------------------\n"); 306 | 307 | struct OrderItem* current = order; 308 | while (current != NULL) 309 | { 310 | printf("| %-23s | %-32s | $%-9.2f | %-8d |\n", current->customerName, current->name, current->price, current->quantity); 311 | current = current->next; 312 | } 313 | } 314 | 315 | printf("======================================================================================\n"); 316 | 317 | } 318 | 319 | 320 | void showtotal(struct OrderItem* order) 321 | { 322 | printf("Total Sale: "); 323 | struct OrderItem* current = order; 324 | double total = 0; // Change to double 325 | while (current != NULL) 326 | { 327 | total += current->price; 328 | current = current->next; 329 | } 330 | 331 | printf("$%.2f\n", total); // Change to %f for double 332 | } 333 | 334 | float getPriceByName(struct FoodItem* menu,char name[]) 335 | { 336 | struct FoodItem* current = menu; 337 | while (current != NULL) 338 | { 339 | if (strcmp(current->name, name) == 0) 340 | { 341 | return current->price; 342 | } 343 | current = current->next; 344 | } 345 | return 0.0; // Return 0 if the item is not found (you may choose a different value) 346 | } 347 | /****************************************************************************** 348 | * File Operation * 349 | ******************************************************************************/ 350 | /** 351 | * @brief Loads the menu from the "menu.txt" file into a linked list. 352 | * 353 | * @return Pointer to the head of the loaded FoodItem linked list. 354 | */ 355 | struct FoodItem* loadMenuFromFile() 356 | { 357 | struct FoodItem* head = NULL; 358 | FILE* file = fopen("menu.txt", "r"); 359 | if (file != NULL) 360 | { 361 | char name[50]; 362 | float price; 363 | int quantity; 364 | char customerName[100]; 365 | while (fscanf(file, "%s %f %d\n", name, &price, &quantity) == 3) 366 | { 367 | struct FoodItem* newItem = createFoodItemNode(name, price, quantity); 368 | if (newItem != NULL) 369 | { 370 | newItem->next = head; 371 | head = newItem; 372 | } 373 | } 374 | fclose(file); 375 | 376 | } 377 | else 378 | { 379 | printf("Menu file not found. Starting with an empty menu.\n"); 380 | } 381 | return head; 382 | } 383 | /** 384 | * @brief Saves the current menu to the "menu.txt" file. 385 | * 386 | * @param head Pointer to the head of the FoodItem linked list. 387 | */ 388 | void saveMenuToFile(struct FoodItem* head) 389 | { 390 | FILE* file = fopen("menu.txt", "w"); 391 | if (file != NULL) 392 | { 393 | struct FoodItem* current = head; 394 | while (current != NULL) 395 | { 396 | fprintf(file, "%s %.2f %d\n", current->name, current->price, current->quantity); 397 | current = current->next; 398 | } 399 | fclose(file); 400 | 401 | } 402 | else 403 | { 404 | printf("Error: Unable to save menu items.\n"); 405 | } 406 | } 407 | /** 408 | * @brief Deletes a food item from the menu file. 409 | * 410 | * @param itemName Name of the food item to be deleted. 411 | */ 412 | void deleteItemFromFile(const char* itemName) 413 | { 414 | FILE* file = fopen("menu.txt", "r"); 415 | if (file == NULL) 416 | { 417 | printf("Menu file not found.\n"); 418 | return; 419 | } 420 | 421 | FILE* tempFile = fopen("temp_menu.txt", "w"); 422 | if (tempFile == NULL) 423 | { 424 | printf("Error: Unable to create temporary file.\n"); 425 | fclose(file); 426 | return; 427 | } 428 | 429 | char name[50]; 430 | float price; 431 | int quantity; 432 | int itemFound = 0; 433 | 434 | // Read items from the original file, exclude the item to be deleted 435 | while (fscanf(file, "%s %f %d\n", name, &price, &quantity) == 3) 436 | { 437 | if (strcmp(name, itemName) == 0) 438 | { 439 | itemFound = 1; 440 | continue; // Skip the item to be deleted 441 | } 442 | fprintf(tempFile, "%s %.2f %d\n", name, price, quantity); 443 | } 444 | 445 | fclose(file); 446 | fclose(tempFile); 447 | 448 | // Remove the original file and rename the temporary file to the original filename 449 | remove("menu.txt"); 450 | rename("temp_menu.txt", "menu.txt"); 451 | 452 | if (itemFound) 453 | { 454 | printf("Item \"%s\" deleted from the menu.\n", itemName); 455 | } 456 | else 457 | { 458 | printf("Item \"%s\" not found in the menu.\n", itemName); 459 | } 460 | } 461 | /****************************************************************************** 462 | * Stack Operation * 463 | ******************************************************************************/ 464 | 465 | /** 466 | * @brief Creates a new StackNode with the given parameters. 467 | * 468 | * @param tableNumber The table number. 469 | * @param orderInfo Pointer to the OrderItem associated with the table. 470 | * @return Pointer to the newly created StackNode. 471 | */ 472 | struct StackNode* createStackNode(char customerName[],struct OrderItem* orderInfo) 473 | { 474 | int tableNumber = rand() % 10 + 1; 475 | 476 | struct StackNode* newNode = (struct StackNode*)malloc(sizeof(struct StackNode)); 477 | if (newNode != NULL) 478 | { 479 | newNode->tableNumber = tableNumber; 480 | strcpy(newNode->customerName, customerName); 481 | newNode->orderInfo = orderInfo; 482 | newNode->next = NULL; 483 | } 484 | return newNode; 485 | } 486 | 487 | /** 488 | * @brief Pushes a table number and order information onto the stack. 489 | * 490 | * @param stack Pointer to the Stack. 491 | * @param tableNumber The table number to be pushed. 492 | * @param orderInfo Pointer to the OrderItem associated with the table. 493 | */ 494 | 495 | void push(struct StackNode **top,char customerName[], struct OrderItem* orderInfo) 496 | { 497 | struct StackNode* newNode = createStackNode(customerName, orderInfo); 498 | if (newNode != NULL) 499 | { 500 | newNode->next = *top; 501 | *top = newNode; 502 | } 503 | 504 | } 505 | /** 506 | * @brief Pops a table number and order information from the stack. 507 | * 508 | * @param stack Pointer to the Stack. 509 | * @return Pointer to the popped StackNode. 510 | */ 511 | struct StackNode* pop(struct StackNode **top) 512 | { 513 | if (*top == NULL) 514 | { 515 | printf("Stack is empty.\n"); 516 | return NULL; 517 | } 518 | 519 | struct StackNode* temp = *top; 520 | *top = (*top)->next; 521 | free(temp); 522 | 523 | return temp; 524 | } 525 | void displaystack(struct StackNode* top) 526 | { 527 | if(top != NULL) 528 | { 529 | printf("\n=================================================\n"); 530 | printf("| %-15s | %-15s |\n", "Table Number", "Customer Name\n"); 531 | printf("==================================================\n"); 532 | 533 | while (top != NULL) 534 | { 535 | printf("| %-15d | %-15s |\n", top->tableNumber, top->customerName); // Update "Details" based on your order information 536 | top = top->next; 537 | } 538 | 539 | printf("==================================================\n"); 540 | } 541 | else 542 | { 543 | printf("=================================================\n"); 544 | printf(" No Data In stack \n"); 545 | printf("=================================================\n"); 546 | } 547 | } 548 | 549 | void clearStack(struct StackNode **top) 550 | { 551 | while (*top != NULL) 552 | { 553 | struct StackNode *temp = *top; 554 | *top = (*top)->next; 555 | free(temp); 556 | } 557 | 558 | printf("Stack cleared successfully.\n"); 559 | } 560 | /****************************************************************************** 561 | * Queue Operation * 562 | ******************************************************************************/ 563 | /** 564 | * @brief Loads the menu from the "menu.txt" file into a linked list. 565 | * 566 | * @return Pointer to the head of the loaded FoodItem linked list. 567 | */ 568 | struct OrderQueueNode* createOrderQueueNode(struct FoodItem* data) 569 | { 570 | struct OrderQueueNode* newNode = (struct OrderQueueNode*)malloc(sizeof(struct OrderQueueNode)); 571 | if (newNode != NULL) 572 | { 573 | newNode->data = data; 574 | newNode->next = NULL; 575 | } 576 | return newNode; 577 | } 578 | 579 | /** 580 | * @brief Checks if the order queue is empty. 581 | * 582 | * @param orderQueue Pointer to the OrderQueue structure. 583 | * @return 1 if the order queue is empty, 0 otherwise. 584 | */ 585 | int isOrderQueueEmpty(struct OrderQueue* orderQueue) 586 | { 587 | return front == NULL; 588 | } 589 | 590 | /** 591 | * @brief Enqueues a food item into the order queue. 592 | * 593 | * @param front Pointer to the front of the OrderQueue. 594 | * @param rear Pointer to the rear of the OrderQueue. 595 | * @param data Pointer to the OrderItem data to be enqueued. 596 | */ 597 | void enqueueOrder(struct OrderQueueNode** front, struct OrderQueueNode** rear, struct OrderItem* data) 598 | { 599 | struct OrderQueueNode* newNode = createOrderQueueNode(data); 600 | if (newNode != NULL) 601 | { 602 | if (*front == NULL) 603 | { 604 | *front = *rear = newNode; 605 | } 606 | else 607 | { 608 | (*rear)->next = newNode; 609 | *rear = newNode; 610 | } 611 | } 612 | } 613 | /** 614 | * @brief Enqueues a food item into the order queue. 615 | * 616 | * @param front Pointer to the front of the OrderQueue. 617 | * @param rear Pointer to the rear of the OrderQueue. 618 | * @param data Pointer to the OrderItem data to be enqueued. 619 | */ 620 | struct OrderQueueNode* dequeueOrder(struct OrderQueueNode** front) 621 | { 622 | if (*front == NULL) 623 | { 624 | printf("Order Queue is empty.\n"); 625 | return NULL; 626 | } 627 | 628 | struct OrderQueueNode* temp = *front; 629 | *front = (*front)->next; 630 | 631 | printf("\n=============================================================\n"); 632 | printf("Processing order: %s - Quantity: %d - Customer: %s\n", temp->data->name, temp->data->quantity, temp->data->customerName); 633 | fflush(stdout); // Flush the output buffer to display the loading animation immediately 634 | 635 | 636 | for (int i = 0; i < 25; ++i) 637 | { 638 | printf("."); 639 | fflush(stdout); 640 | usleep(50000); // Introduce a delay of 500,000 microseconds (0.5 seconds) between dots 641 | } 642 | 643 | printf("\n"); 644 | 645 | printf("Order processed: %s - Quantity: %d - Customer: %s\n", temp->data->name, temp->data->quantity, temp->data->customerName); 646 | 647 | free(temp->data); // Assuming that data is dynamically allocated 648 | free(temp); 649 | 650 | return temp; // Return the dequeued node 651 | } 652 | 653 | /** 654 | * @brief Displays the current order queue with order details. 655 | * 656 | * @param front Pointer to the front of the OrderQueue. 657 | */ 658 | void displayOrderQueue(struct OrderQueueNode** front) 659 | { 660 | if (*front != NULL) 661 | { 662 | printf("=========================================================================================================\n"); 663 | printf("| %-5s | %-20s | %-30s | %-10s | %-20s |\n", "S.No.", "Customer Name", "Item Name", "Quantity", "Price"); 664 | printf("=========================================================================================================\n"); 665 | 666 | struct OrderQueueNode* current = *front; 667 | int serialNumber = 1; 668 | while (current != NULL) 669 | { 670 | printf("| %-5d | %-20s | %-30s | %-10d | $%-20.2f |\n", serialNumber, current->data->customerName, current->data->name, current->data->quantity, current->data->price); 671 | current = current->next; 672 | serialNumber++; 673 | } 674 | 675 | printf("=========================================================================================================\n"); 676 | } 677 | else 678 | { 679 | printf("=========================================================================================================\n"); 680 | printf(" No Order queue\n"); 681 | printf("=========================================================================================================\n"); 682 | } 683 | } 684 | 685 | /****************************************************************************** 686 | * Free Memory * 687 | ******************************************************************************/ 688 | /** 689 | * @brief Frees the memory allocated for the FoodItem and OrderItem linked lists. 690 | * 691 | * @param menu Pointer to the head of the FoodItem linked list. 692 | * @param order Pointer to the head of the OrderItem linked list. 693 | */ 694 | void freeMenuAndOrder(struct FoodItem* menu, struct OrderItem* order) 695 | { 696 | while (menu != NULL) 697 | { 698 | struct FoodItem* tempMenu = menu; 699 | menu = menu->next; 700 | free(tempMenu); 701 | } 702 | 703 | while (order != NULL) 704 | { 705 | struct OrderItem* tempOrder = order; 706 | order = order->next; 707 | free(tempOrder); 708 | } 709 | } 710 | 711 | int main() 712 | { 713 | struct FoodItem* menu = NULL; 714 | struct OrderItem* order = NULL; 715 | struct OrderQueueNode* orderQueue = NULL; 716 | struct StackNode* top = NULL; 717 | 718 | a: 719 | menu = loadMenuFromFile(); 720 | printf("Welcome to Cafeteria Management System\n"); 721 | int choice; 722 | char itemName[50]; 723 | float itemPrice; 724 | int itemQuantity; 725 | char customerName[100]; 726 | char editItemName[50]; 727 | int isAuthenticated = 0; 728 | 729 | do 730 | { 731 | printf("\n1. Display Menu\n"); 732 | printf("2. Place Order\n"); 733 | printf("3. Display Order Queue\n"); 734 | printf("4. Admin Login\n"); 735 | printf("5. Exit\n"); 736 | printf("Enter your choice: "); 737 | scanf("%d", &choice); 738 | 739 | switch (choice) 740 | { 741 | case 1: 742 | displayMenu(menu); 743 | break; 744 | case 2: 745 | printf("Enter your name: "); 746 | scanf("%s", customerName); 747 | printf("Enter item name to order: "); 748 | scanf("%s", itemName); 749 | printf("Enter quantity to order: "); 750 | scanf("%d", &itemQuantity); 751 | if(placeOrder(&menu, &order, itemName, itemQuantity, customerName) == 1) 752 | { 753 | itemPrice = getPriceByName(menu, itemName); 754 | 755 | struct FoodItem* orderedItem = createFoodItemNode(itemName, itemPrice, itemQuantity); 756 | enqueueOrder(&front, &rear, createOrderItemNode(itemName, itemPrice, itemQuantity, customerName)); 757 | push(&top,customerName,createOrderItemNode(itemName, itemPrice, itemQuantity, customerName)); 758 | 759 | } 760 | 761 | break; 762 | case 3: 763 | displayOrderQueue(&front); 764 | break; 765 | case 4: 766 | isAuthenticated = authenticate(&admin); 767 | break; 768 | case 5: 769 | goto b; 770 | break; 771 | default: 772 | printf("Invalid choice.\n"); 773 | 774 | } 775 | 776 | if (isAuthenticated) 777 | 778 | 779 | { 780 | do 781 | { 782 | printf("\nCafeteria Management System\n"); 783 | printf("Enter your choice: \n"); 784 | printf("1. Add Food Item\n"); 785 | printf("2. Edit Food Item\n"); 786 | printf("3. Delete Food Item\n"); 787 | printf("4. Place Order\n"); 788 | printf("5. Display Menu\n"); 789 | printf("6. Display Order Summary\n"); 790 | printf("7. Display stack\n"); 791 | printf("8. Display Order queue\n"); 792 | printf("9. Process one Order \n"); 793 | printf("10. Exit\n"); 794 | printf("Enter your choice: "); 795 | scanf("%d", &choice); 796 | 797 | switch (choice) 798 | { 799 | case 1: 800 | printf("Enter item name: "); 801 | scanf("%s", itemName); 802 | printf("Enter item price: "); 803 | scanf("%f", &itemPrice); 804 | printf("Enter item quantity: "); 805 | scanf("%d", &itemQuantity); 806 | addFoodItem(&menu, itemName, itemPrice, itemQuantity); 807 | break; 808 | case 2: 809 | // New case to edit a food item 810 | printf("Enter the name of the item to edit: "); 811 | scanf("%s", editItemName); 812 | editFoodItem(&menu, editItemName); 813 | break; 814 | case 3: 815 | printf("Enter item name to delete: "); 816 | scanf("%s", itemName); 817 | deleteItemFromFile(itemName); 818 | deleteFoodItem(&menu, itemName); 819 | break; 820 | case 4: 821 | printf("Enter customer's name: "); 822 | scanf("%s", customerName); 823 | printf("Enter item name to order: "); 824 | scanf("%s", itemName); 825 | printf("Enter quantity to order: "); 826 | scanf("%d", &itemQuantity); 827 | if(placeOrder(&menu, &order, itemName, itemQuantity, customerName) == 1) 828 | { 829 | itemPrice = getPriceByName(menu, itemName); 830 | 831 | struct FoodItem* orderedItem = createFoodItemNode(itemName, itemPrice, itemQuantity); 832 | enqueueOrder(&front, &rear, createOrderItemNode(itemName, itemPrice, itemQuantity, customerName)); 833 | push(&top,customerName,createOrderItemNode(itemName, itemPrice, itemQuantity, customerName)); 834 | 835 | } 836 | 837 | break; 838 | case 5: 839 | displayMenu(menu); 840 | break; 841 | case 6: 842 | displayOrderSummary(order); 843 | showtotal(order); 844 | break; 845 | 846 | case 7: 847 | displaystack(top); 848 | break; 849 | case 8: 850 | displayOrderQueue(&front); 851 | break; 852 | case 9: 853 | if (!isOrderQueueEmpty(&front)) 854 | { 855 | // 856 | dequeueOrder(&front); 857 | 858 | } 859 | else 860 | { 861 | printf("Order Queue is empty. No orders to process.\n"); 862 | } 863 | break; 864 | case 10: 865 | saveMenuToFile(menu); 866 | goto a; 867 | break; 868 | 869 | 870 | 871 | default: 872 | printf("Invalid choice! Please enter a valid option.\n"); 873 | } 874 | } 875 | while (choice != 11); 876 | } 877 | } 878 | while (choice != 5); 879 | b: 880 | freeMenuAndOrder(menu, order); 881 | menu = NULL; 882 | order = NULL; 883 | 884 | while (front != NULL) 885 | { 886 | struct OrderQueueNode* temp = front; 887 | front = (front)->next; 888 | free(temp->data); 889 | free(temp); 890 | } 891 | 892 | while (top != NULL) 893 | { 894 | struct StackNode* temp = top; 895 | top = top->next; 896 | free(temp->orderInfo); 897 | free(temp); 898 | } 899 | 900 | printf("\nThank you for using Cafeteria Management System!\n"); 901 | return 0; 902 | } 903 | 904 | 905 | 906 | --------------------------------------------------------------------------------