Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

What the FUCK

Name: Anonymous 2009-11-25 21:00

I keep getting "in main, syntax error before employee"
I've tried every conceivable solution, what the FUCK am I doing wrong?

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

#define empmax  20
#define MAX_LEN 30
#define regtax  .10
#define overtax .20

struct employee{
  char first[MAX_LEN];
  char last[MAX_LEN];
  double payperhr;
  double gross;
  double taxes;
  double hours_in_week;
};

typedef struct employee employee;

void getclock(employee *array);
FILE *gfopen(char name[], char mode[]);

int main(){
   
   
    employee array[empmax];
   
    getclock(struct employee *array);
   
    system("pause");
   
    return 0;
}

void getclock(employee *array){
     char tempfirst[MAX_LEN], templast[MAX_LEN];
     int i, j, k, l, empnum, numweeks, numshifts;
     double timeinhr, timeinmin, timeouthr, timeoutmin, timeinshift, overhours, taxpayed, grossearned, netpay;
     FILE *input;
    
     input = gfopen("clock.txt", "r");
    
     fscanf(input, "%d", empnum);
     for(i=0; i<empnum; i++){
              fscanf(input, "%s %s %d", array[i].first, array[i].last, &array[i].payperhr);
              }
             
     //Scans number of weeks on file, goes through each week
     fscanf(input, "%d", &numweeks);
     for(i=0; i<numweeks; i++){
             
              //Scans for number of shifts in each week
              fscanf(input, "%d", &numshifts);
             
              //Goes through each shift
              for(j=0;j<numshifts;j++){
              fscanf(input, "%s %s", tempfirst, templast);
             
              //Finds out who the shift belongs to
              for(k=0;k<empnum;k++){
              //Adds all the hours in the shifts belonging to each person
              if(strcmp(array[k].first, tempfirst)==0 && strcmp(array[k].last, templast)==0){
              fscanf(input, "%lf %lf %lf %lf", &timeinhr, timeinmin, timeouthr, timeinmin);
                            timeinmin=timeinmin/60;
                            timeoutmin=timeoutmin/60;
                            timeinshift=(timeouthr+timeoutmin)-(timeinhr+timeinmin);
                            array[k].hours_in_week=array[k].hours_in_week+timeinshift;
                            }//Closes if statement
                            }//Closes shift ownership loop
                            }//Closes shift loop
                           
                            //Takes the hours worked in week for each person and calculates earnings and taxes
                            for(l=0;l<empnum;l++){
                            //Determines if hour worked for the person is over 40
                            if(array[l].hours_in_week>40){
                            overhours=array[l].hours_in_week-40;
                            grossearned=(overhours*array[l].payperhr*1.5)+(40*array[l].payperhr);
                            taxpayed=(overhours*array[l].payperhr*1.5)*.20+(40*array[l].payperhr)*.10;
                            array[l].gross=array[l].gross+grossearned;
                            array[l].taxes=array[l].taxes+taxpayed;
                            }
                           
                            else if(array[l].hours_in_week<41){
                            grossearned=array[l].payperhr*array[l].hours_in_week;
                            taxpayed=grossearned*.10;
                            }
                           
                            //Resets weekly hour counter
                            array[l].hours_in_week=0;
                           
                            }//Closes earnings and taxes calculation loop
                            }//Closes number of shifts counter
                            }//Closes weeks loop

                           
                           
//File open function
FILE *gfopen(char name[], char mode[]){
     FILE *input;
     input = fopen(name, mode);
     if(input == NULL)
     {
              printf("Error opening file %s, aborting.\n", name);
              exit(1);
              }
     return input;
}

Name: Anonymous 2009-11-25 21:18

1. Don't "typedef struct this this" because the compiler won't know whether "this" refers to the actual struct name or the typedef alias.  This "struct this" can be interpreted as "struct struct this" because "this" is already aliased to "struct this".
2. Apparently it confuses you as well as the compiler because on this line:
   getclock(struct employee *array);
you still somehow feel the need to explicity call employee a struct, and then call it as if it were the prototype, or something.

Anyways, only like the first 30-40 lines need to be changed.

Here, I fixed your immense fail for you:

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

#define empmax  20
#define MAX_LEN 30
#define regtax  .10
#define overtax .20

typedef struct employee {
  char first[MAX_LEN];
  char last[MAX_LEN];
  double payperhr;
  double gross;
  double taxes;
  double hours_in_week;
} employee_t;


void getclock(employee_t *array);
FILE *gfopen(char name[], char mode[]);

int main(){
  
  
    employee_t array[empmax];
  
    getclock(array);
  
    system("pause");
  
    return 0;
}

void getclock(employee_t *array){



That will be $20.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List