Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- FILE *empinfo;
- struct employeeData {
- int EMP_ID;
- char name[20];
- int dept;
- int rank;
- double salary;
- struct employeeData *next;
- };
- struct employeeData *head = NULL;
- void initializeList();
- void add();
- void deleteEmp(int ID);
- void modify(int ID, double NewSalary);
- void query(int rank);
- void print();
- void main(){
- int choice=1, ID, rank;
- double newSalary;
- initializeList();
- while (choice != 0) {
- printf("1-Add 2-Delete 3-Modify 4-Query 5-Print 0-Exit\n");
- scanf("%d", &choice);
- if (choice == 1) {
- add();
- }
- else if (choice == 2){
- printf("Enter employee ID to delete: ");
- scanf("%d", &ID);
- deleteEmp(ID);
- }
- else if (choice == 3){
- printf("Enter employee ID to modify: ");
- scanf("%d", &ID);
- printf("Enter new salary amount: ");
- scanf("%lf", &newSalary);
- modify(ID,newSalary);
- }
- else if (choice == 4){
- printf("Enter the rank you wish to query: ");
- scanf("%d", &rank);
- query(rank);
- }
- else if (choice == 5){
- print();
- }
- }
- printf("Goodbye...\n");
- return;
- }
- void initializeList(){
- head = NULL;
- empinfo=fopen("empinfo.txt", "r");
- head = (struct employeeData *)malloc(sizeof(struct employeeData));
- head->next = NULL;
- struct employeeData *tempPtr = head;
- while (tempPtr->EMP_ID != 0){
- fscanf(empinfo, "%d %s %d %d %lf", &tempPtr->EMP_ID, &tempPtr->name, &tempPtr->dept, &tempPtr->rank, &tempPtr->salary);
- printf("%d %s %d %d %lf\n", tempPtr->EMP_ID, tempPtr->name, tempPtr->dept, tempPtr->rank, tempPtr->salary);
- if (tempPtr->EMP_ID == 0){
- free(tempPtr);
- break;
- }
- tempPtr->next = (struct employeeData *)malloc(sizeof(struct employeeData));
- tempPtr=tempPtr->next;
- }
- }
- void add(){
- }
- void deleteEmp(int ID){
- }
- void modify(int ID, double NewSalary){
- }
- void query(int rank){
- }
- void print(){
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement