-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BLABLABLA
- Loading branch information
Thiago M
committed
Sep 24, 2015
1 parent
fd721e4
commit ad135a3
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* employee database program */ | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
typedef struct vehicle | ||
{ | ||
char name[100]; | ||
int roll; | ||
int salary; | ||
char address[100]; | ||
int join_year; | ||
}record; | ||
|
||
int main(void) | ||
{ | ||
int i , choice; | ||
FILE *fp1,*fp2; | ||
char oname[100]; | ||
record det; | ||
int recsize; | ||
char c; | ||
|
||
fp1 = fopen("record.txt" , "r+"); | ||
if(fp1 == NULL) | ||
{ | ||
fp1 = fopen("record.txt" , "w+"); | ||
if(fp1 == NULL) | ||
{ | ||
printf("error in opening file : \n"); | ||
return -1; | ||
} | ||
} | ||
recsize = sizeof(det); | ||
|
||
fseek(fp1 , 0 ,SEEK_END); | ||
printf("Enter employee Name : "); | ||
scanf("%[^\n]" , det.name); | ||
printf("Enter roll number : "); | ||
scanf("%d" , &det.roll); | ||
printf("Enter the salary : "); | ||
scanf("%d" , &det.salary); | ||
scanf("%c" , &c); | ||
printf("Enter address : "); | ||
scanf("%[^\n]" , det.address); | ||
printf("Enter joining year : "); | ||
scanf("%d" , &det.join_year); | ||
fwrite(&det,recsize,1,fp1); | ||
} |