Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include <stdlib.h>
- #include<malloc.h>
- struct employee {
- char name[128];
- float salary;
- };
- typedef struct employee Employee;
- int main(){
- int n = 3;
- Employee i[3];
- strcpy(i[0].name, "Jonh Doe");
- i[0].salary = 3000.0;
- strcpy(i[1].name, "Mark Ken");
- i[1].salary = 2300.0;
- strcpy(i[2].name, "Sucy Merc");
- i[2].salary = 2000.0;
- FILE *fp = fopen("D:\\employee.bin","w+b");
- fwrite(&n, sizeof(int),1,fp);
- fwrite(i, sizeof(Employee), 3, fp);
- fclose(fp);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement