Payroll Data Entry using File handling in C
Payroll Data Entry using file handling in c Here you will get a source code of Payroll Data Entry using File handling in C example with c language. File Handling […]
Payroll Data Entry using file handling in c Here you will get a source code of Payroll Data Entry using File handling in C example with c language. File Handling […]
Employee Record System in C Here you will get the program code of Employee Record System in C using File Handling. Employee Record System in C using File Handling
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | #include<stdlib.h> #include<conio.h> #include<stdio.h> #include<string.h> main() { FILE *fp,*ft; char another,choice; struct emp { char name[40]; int age; float bs; }; struct emp e; char empname[40]; long int recsize; clrscr(); fp=fopen("EMP.DAT","rb+"); if ( fp== NULL) { fp= fopen("EMP.DAT ","wb+"); if (fp==NULL) { puts("\nCannot open file"); exit(1); } } recsize= sizeof(e); while(1) { gotoxy(10,10); printf("1. Add Records"); gotoxy(10,12); printf("2. Display Records"); gotoxy(10,14); printf("3. Modify Records"); gotoxy(10,16); printf("4. Delete Records"); gotoxy(10,18); printf(" 0. Exit"); gotoxy(10,20); printf("Your choice"); fflush(stdin); choice=getche(); switch(choice) { case'1': clrscr(); fseek(fp,0,SEEK_END); another='Y'; while(another=='Y') { printf("\n Enter name, age and basic sal"); scanf("%s%d%f",e.name,&e.age,&e.bs); fwrite(&e,recsize,1,fp); printf("\n Add another record(Y/N)"); fflush(stdin); another= getche(); } break; case'2': clrscr(); rewind(fp); while( fread(&e,recsize,1,fp)==1) printf("\n%s %d %f",e.name,e.age,e.bs); break; case'3': clrscr(); another='Y'; while(another=='Y') { printf("\n Enter name of employee to modify"); scanf("%s",empname); rewind(fp); while(fread(&e,recsize,1,fp)==1) { if (strcmp(e.name,empname)==0) { printf("\n Enter new name , age & bs"); scanf("%s%d%f",e.name,&e.age,&e.bs); fseek(fp,recsize,SEEK_CUR); fwrite(&e,recsize,1,fp); break; } } printf("\nModify another record(Y/N)"); fflush(stdin); another=getche(); } break; case'4': clrscr(); another='Y'; while( another=='Y') { printf("\n Enter name of employeeto delete"); scanf("%s", empname); ft=fopen("TEMP.DAT","wb"); rewind(fp); while(fread(&e,recsize,1,fp)==1) { if (strcmp(e.name,empname)!=0) fwrite(&e,recsize,1,ft); } fclose(fp); fclose(ft); remove("TEMP.DAT"); rename("TEMP.DAT","EMP.DAT"); fp=fopen("EMP.DAT","rb+"); printf("\nDo you want to Delete another record(Y/N)"); fflush(stdin); another=getche(); } break; case'0': fclose(fp); exit(1); } } } |
Floyds Triangle in C In this program, you will get and learn the program code of floyds triangle in c programming. Floyd’s triangle is a triangular shaped, array of natural
Calculator Program in C Here you get the example code of Calculator Program in C using Switch Case. Calculator definition: An electronics machine, that is used to do the arithmetical