This program is driving me crazy. I'm relatively new to programming and I can't figure out how to fix the error in the title (line 50). I'd really appreciate any help.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define SIZE 20 //constants defined before main
#define MAX_LEN 30

double calchours(int hrin, int minin, int hrout, int minout); //declare function

struct employee { //structure defined before main
  char first [MAX_LEN];
  char last [MAX_LEN];
  double payperhr;
  double gross;
  double taxes;
  double hours_in_week;
};

  

int main() {

int i, j, n, k, m, hrin, minin, hrout, minout, temphours; //defined variables
char first, last, L; //defined variables of character-type

FILE* ifp; //read in clock2 text file
ifp = fopen("clock2.txt","r");

struct employee workers[SIZE]; //initialize size of struct

for (i=0; i<n; i++) {
fscanf (ifp,"%s%s%lf", workers [i].first, workers [i].last, workers [i].payperhr);
}//reads in first and last names of employees along with pay per hour

fscanf(ifp,"%d", &k);

for(i=0; i<k; i++) { //loop
    for(j=0; j<n; j++) {
        workers[j].hours_in_week = 0;
        }
        
        fscanf(ifp, "%d", &m);
    
    for(i=0; i<m; i++) {
       fscanf(ifp, "%s%s%d%d%d%d", last, first, &hrin, &minin, &hrout, &minout);
       temphours = calchours(hrin, minin, hrout, minout);
       
       for(L=0; L<n; L++) {
          if(strcmp(first, workers[L].first) == 0 && (last, workers[L].last) == 0) {
             workers[L].hours_in_week += temphours;
             }
             }
}             
                              
     for(j=0; j<n; j++) {
         if(workers[j].hours_in_week > 40) {
            workers [j].gross += (40 * workers[j].payperhr) + (workers[j].hours_in_week        
            -40) * 1.5 * workers[j].payperhr;
            
            workers[j].taxes += 0.1 * (40 * workers[j].payperhr) + 0.2 * 
            (workers[j].hours_in_week - 40) * 1.5 * workers[j].payperhr;
            
            }
            }
}            
fclose(ifp); //closes clock2 text file

FILE *ofp;
ofp = fopen("w2.txt", "w"); //writes employee pay info to w2 text file

fprintf(ofp, "w2 Form\n"); //prints heading of w2 form
fprintf(ofp, "-------\n");

for(j=0; j<n; j++) //loop that prints actual w2 form
    fprintf(ofp, "Name %s  %s\n", workers[j].first, workers[j].last);
    fprintf(ofp, "Gross Pay %lf\n", workers[j].gross);
    fprintf(ofp, "Taxes Withheld %lf\n", workers[j].taxes);
    fprintf(ofp, "Net Pay %lf", workers[j].gross - workers[j].taxes);
    

system("PAUSE");
return 0;
}
//function that calculates hours worked
double calchours(int hrin, int minin, int hrout, int minout) { 
       int hours = hrout - hrin; //total hours
       int min = minout - minin; //total minutes
       if(min < 0) {
          min += 60;
          hours--;

}
double tothours = hours + 1.0 * min/60; //total hours as a double
return tothours; //returns total hours to main
}

Shouldn't this line be

if((strcmp(first, workers[L].first) == 0) && (strcmp(last, workers[L].last) == 0))

calling strcmp twice.

Also your error...first and last are characters not c-strings.

Shouldn't this line be

if((strcmp(first, workers[L].first) == 0) && (strcmp(last, workers[L].last) == 0))

calling strcmp twice.

Also your error...first and last are characters not c-strings.

Ok thanks. Yeah I forgot about the other 'strcmp'. If you don't mind me asking what should I do to first and last to fix the error?

so how do you fix this ?? how do i compare characters ?

how do i compare characters ?

With the relational operators (ex. first == last ). But in your case first and last should be arrays of char, not char. You're using them as strings, after all.

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.