#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<iomanip.h>

FILE *fp1, *fp2;
int count;
    struct record
    {
    char name[20];
    int empnum;
    char depart[20];
    float hours;
    float rate;
    };

void main()
{
 clrscr();
 record h;
 int acount=0,adcount=0,scount=0;
 float grosspay,totalg=0;
 float tax,totalt=0;
 float health,totalh=0;
 float pension,totalp=0;
 float netpay,totaln=0;
 float deductions;

 fp1=fopen("employ.dat","r");
 fp2=fopen("payrol.dat","w");
 count = 0;
 printf("                       ""Page1\n");
 printf("        ""ABC COMPANY EMPLOYEE REPORT""\n");
 printf("------------------------------------------\n");
 printf("%5s %20s %10s %12s %5s %10s %9s %7s\n","Name","Empnumber","Depart","Tax","Health","Pension","Netpay");
 printf("___________________________________________________________________________________\n");

 while(fread(&h,sizeof(struct record),1,fp1)==1)
    {
    grosspay=h.hours*h.rate;
    tax = 0.155 * grosspay;
    pension=0.03*grosspay;
    deductions=(tax+health+pension);
    netpay=grosspay-deductions;
    totalg=totalg+grosspay;
    totalt=totalt+tax;
    totalh=totalp+pension;
    totaln=totaln+netpay;

    printf("%2s\t %5d\t %10s\t %4.2f\t %4.2f\t %4.2f\t %4.2f\t %4.2f\n",h.name,h.empnum,h.depart,grosspay,tax,health,pension,netpay);
      if(strcmp(h.depart,"Sales")==0
      scount=scount+1;
      else if(strcmp(h.depart,"Admin")==0)
      adcount=adcount+1;
      else
      acount=acount+1;
      count++;
    }
    printf("__________________________________________\n");
    printf("TOTALS     %4.2f\t %4.2\t %4.2f\t %4.2f\t %4.2f\n",totalg,totalt,totalh,totalp,totaln);

    printf("Total Number From Sales Department:%d\n",scount);
        printf("Total Number From Sales Department:%d\n",scount);
        printf("Total Number From Admin Department:%d\n",adcount);
        printf("Total Number From Accounts Department:%d\n",&acount);
        printf("Total Number Of Employees:%d\n",count);
        fwrite(&h,sizeof(h),1,fp2);
        fflush(stdin);
        fclose(fp1);
        fclose(fp2);
}

Maybe your issue is related to the missing ).

if(strcmp(h.depart,"Sales")==0

[EDIT]Oh, wait! Are you compiling C++ code in a C compiler?

Oh, wait! Are you compiling C++ code in a C compiler?

I was wandering the same thing

#include<iomanip.h>

==> C++ code.

sizeof(struct record)

==> C code ?? .

its supposed to be in c code.i dont know if that is the right way of coding.

<iomanip.h> is a (deprected) C++ header that most likely rightly caused the error. Delete this #include (you're not using anything in it in the code anyway).

C requires you to declare all variables before executing statements (unless you are using C99), so you would need to move the call to clrscr() after the declarations.

C does not automatically typedef structures, so this

record h;

should be this.

struct record h;

Your main should return an int, not void. As such, return 0 is most commonly used.

Here:

deductions=(tax+health+pension);

the variable health is used before it has been given a value.

And fflush(stdin) is a no-no.

><iomanip.h> is a (deprected) C++ header
Nope, iostream.h was removed completely. Deprecated presumes that the header is still valid C++, but not recommented as it might be removed in future revisions. As it is, iostream.h is nonstandard and should be treated as such.

I"ve done all the changes but still it wont run please help

>I"ve done all the changes
Prove it.

>but still it wont run
What's it saying?

>please help
You're not helping us to help you, so you won't get much help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.