Question #213315

The file named called EMPLOYEE.txt contains employee details such as employee number, name, designation and salary of employee. Write a program to create a file to store the details of employee (Use of structure and fwrite () & fread () functions).


1
Expert's answer
2021-07-05T01:07:10-0400
#include <stdio.h>


struct Employee {
    int number;
    char name[20];
    char design[20];
    int salary;
};


int main() {
    struct Employee data[5] =  {{1"John Smith""AAA"10000},
                           {2"Adam Brown""BBB"20000},
                           {3"Bob Armor""CCC"15000},
                           {4"Charly Crown""DDD"25000},
                           {5"Duglas Dow""EEE"1000}};
    int i;
    FILE *pFile;


    pFile = fopen("EMPLOYEE.txt""wb");
    fwrite(data, sizeof(struct Employee), 5, pFile);
    fclose(pFile);


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS