Don't know what is up with it.

Any help is nice, thanks.

error c2660: 'Totaler' : Function does not take 20 arguments
error c2660: 'Averager' : Function does not take 30 arguments

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "./myheader.h"

void InputEmployeeData(char*lastname, char*firstname,
                             float*hours, float*payrate, float*deferred);    

float CalcGross(float hours, float payrate);                              

extern void CalcTaxesExt(float gross, float deferred, float *federaltax,
              float *statetax, float *ssitax);                           

void CalcNetPay(float gross, float deferred, float federaltax,
           float statetax, float ssitax, float*netpay);

void AddDetailToAccumulators(float hours, float*reghrs, float*ovthrs);
                                                     
void showReport(FILE*reportfile, char lastname[15+1], char firstname[10+1],
                    float payrate, float reghrs, float gross,
                    float federaltax, float ssitax, float netpay,
                    float ovthrs, float statetax, float deferred);           
void Totaler(float *totfedtax, float *totssitax, float *totstatetax,float *totrate, float *totreg,
			 float *totovt, float *totgross,float *totpay,float *totdeferred, float gross, float federaltax, float statetax,
			float ssitax,float hours, float payrate,float deferred,float reghrs,float ovthrs,float netpay);

void Averager(float *totfedtax, float *totssitax, float *totstatetax,float *totrate, float *totreg,
			 float *totovt, float *totgross,float *totpay,float *totdeferred,float *avgfedtax, float *avgssitax, float *avgstatetaxtax,float *avgrate, float *avgreg,
			 float *avgovt, float *avggross,float *avgpay,float *avgdeferred, float gross, float federaltax, float statetax,
			float ssitax,float hours, float payrate,float deferred,float reghrs,float ovthrs,float netpay);

int main(void)
{
  FILE * reportfile;

  int counter;
  float gross, federaltax,statetax,ssitax,hours, payrate, deferred,
	  reghrs, ovthrs, netpay, totrate, totreg, totgross,
        totfedtax, totssitax, totnet,
        totovt, totstatetax, totdeferred, totpay,
		avgrate, avgreg, avggross,avgfedtax, avgssitax, avgnet,
       avgovt, avgstatetax, avgdeferred, avgpay;

  char lastname[15+1],firstname[10+1], combinedName[25+1];


  reportfile = fopen("./report.txt","wt");
  if (reportfile == NULL)
  {
      printf(" Error opening report file ...\n");
      fflush(stdin);
      getchar();
      exit(-20);
  }
  fprintf(reportfile,REPORTHEADING1);
  fprintf(reportfile,REPORTHEADING2);
  fprintf(reportfile,REPORTHEADING3);
  for (counter=0; counter < MAX; counter++)
  {
	  // data input
      InputEmployeeData(lastname,firstname,&hours,&payrate,&deferred);
      AddDetailToAccumulators(hours,&reghrs,&ovthrs);
      gross = CalcGross(hours,payrate);
      CalcTaxesExt(gross,deferred,&federaltax,&statetax,&ssitax);
      CalcNetPay(gross,deferred,federaltax,statetax,ssitax,&netpay);
      strcpy(combinedName,lastname);
      strcat(combinedName, ", ");
      strcat(combinedName,firstname);

	  // totaller
	  Totaler(gross, federaltax,statetax,ssitax,hours, payrate, deferred,
	  reghrs, ovthrs, netpay, 
	  &totrate, &totreg, &totgross,&totfedtax, &totssitax, &totnet,
       &totovt, &totstatetax, &totdeferred, &totpay);

	  // averager
	  Averager(totrate, totreg, totgross,totfedtax, totssitax, totnet,
       totovt, totstatetax, totdeferred, totpay, gross, federaltax,statetax,ssitax,hours, payrate, deferred,
	  reghrs, ovthrs, netpay,&avgrate, &avgreg, &avggross,&avgfedtax, &avgssitax, &avgnet,
       &avgovt, &avgstatetax, &avgdeferred, &avgpay);
	  
      fprintf(reportfile,REPORTFORMAT1,combinedName,payrate,
                          reghrs,gross,federaltax,ssitax,netpay);
      fprintf(reportfile,REPORTFORMAT2,ovthrs,statetax,deferred);
  }
  fprintf(reportfile,REPORTFORMAT1,totrate,totreg,totgross,totfedtax,totssitax,totnet);
  fprintf(reportfile,REPORTFORMAT2,totovt,totstatetax,totdeferred);
  fprintf(reportfile,REPORTFORMAT1,avgrate,avgreg,avggross,avgfedtax,avgssitax,avgnet);
  fprintf(reportfile,REPORTFORMAT2,avgovt,avgstatetax,avgdeferred);


  fclose(reportfile);
  printf("Press any button to close");
  fflush(stdin);
  getchar();
  return 0;
}

//functions

void showReport(FILE*reportfile, char lastname[15+1], char firstname[10+1],
              float payrate, float reghrs, float gross, 
              float fedtax, float ssitax, float netpay,
              float ovthrs, float statetax, float deferred);


void InputEmployeeData(char *lastname, char *firstname,
               float *hours, float *payrate, float *deferred)
{
   printf("    Enter Employee's Last and First Name  :  ");
   scanf("%s%s",lastname,firstname);
   printf("    Enter Hourly Pay Rate                 :  ");
   scanf("%f",payrate);
   printf("    Enter Total Hours Worked This Period  :  ");
   scanf("%f",hours);
   printf("    Enter Amount of Deferred Earnings     :  ");
   scanf("%f",deferred);
}


void AddDetailToAccumulators(float hours, float*reghrs, float*ovthrs)
{
  if (hours <= 40)
    *reghrs = hours,
    *ovthrs = 0.00;
  else
    *reghrs = 40.00,
    *ovthrs = (hours-40);
}

void CalcNetPay(float gross, float deferred, float fedtax,
           float statetax, float ssitax, float*netpay)
{
  *netpay = (gross-(deferred+fedtax+statetax+ssitax));
}

float CalcGross(float hours, float payrate)
{
  if (hours <= 40)
     return hours * payrate;
  else
     return 40 * payrate + (hours-40) * 1.5 * payrate;
}

void Averager(float totfedtax, float totssitax, float totstatetax,float totrate, float totreg,
			 float totovt, float totgross,float totpay,float totdeferred,
			  float *avgfedtax, float *avgssitax, float *avgstatetax,float *avgrate, float *avgreg,
			 float *avgovt, float *avggross,float *avgpay,float *avgdeferred, float gross, float federaltax, float statetax,
			float ssitax,float hours, float payrate,float deferred,float reghrs,float ovthrs,float netpay)
{
	*avgfedtax=totfedtax/MAX;
	*avgstatetax=totstatetax/MAX;
	*avgssitax=totssitax/MAX;
	*avgrate=totrate/MAX;
	*avgdeferred=totdeferred/MAX;
	*avgreg=totreg/MAX;
	*avgovt=totovt/MAX;
	*avggross=totgross/MAX;
	*avgpay=totpay/MAX;
}


void Totaler(float *totfedtax, float *totssitax, float *totstatetax,float *totrate, float *totreg,
			 float *totovt, float *totgross,float *totpay,float *totdeferred, float gross, float federaltax, float statetax,
			float ssitax,float hours, float payrate,float deferred,float reghrs,float ovthrs,float netpay)
{
	*totfedtax+=federaltax;
	*totstatetax+=statetax;
	*totssitax+=ssitax;
	*totrate+=payrate;
	*totdeferred+=deferred;
	*totreg+=reghrs;
	*totovt+=ovthrs;
	*totgross+=gross;
	*totpay+=netpay;
}

Recommended Answers

All 15 Replies

whoa.. that's just asking for trouble. You should make a struct or a class to contain all that information and just pass around 1 variable, not 20!

Dave

whoa.. that's just asking for trouble. You should make a struct or a class to contain all that information and just pass around 1 variable, not 20!

Dave

one variable at a time would make code long and hard to read :X , but is hard to read as it, helps plox

Hmm I think you're mistaken

You should do something like this

class TaxInfo
{

float totfedtax;
float totssitax;
float totstatetax
etc...
};

void Averager(TaxInfo &MyTax)
{
do stuff to MyTax.totfedtax, etc
}

see how clean it is!?

Dave

This looks like C not C++, so look into creating structs.

yep, exactly the same thing in this case because we haven't used any of the "fancy" ideas of classes. Just replace "class" with "struct".

Dave

maybe variant argument list will do ...

what do you mean xeuron?

maybe variant argument list will do ...

what do you mean xeuron?

Something you don't have to worry about. Use Dave's idea.

Also, read this.

Can someone tell me how to fix the error or direct me to a link or thread on this forum that relates to this error?

Thanks

didn't we answer the question??

didn't we answer the question??

In a way, I combined the 2 different functions into one and the program works now. Still don't really understand why it can't be put into 2 different functions though.

what do you mean xeuron?

sorry, but I think I used wrong phrase ... my poor English :-(
I mean some functions like printf, with a parameter list as printf(const char*, ...);

You probably can put it into 2 different functions. You could probably make it work if you tried hard enough. But was the point to make the two 20 argument functions work or to make the code work?

I don't know if you saw the suggestion, but the creation of a struct that you fill with the arguments and then pass a pointer to the struct is actually a MUCH better implementation than all of the individual parameters.

The struct allows you to set the parameters by name. So to verify that the right data is in the right place is just verifying that the source data is correct for the target member. Validation of the function calls with 20 arguments involves looking at the prototype and parameter counting to make sure you get the data in the right position in the list.

The struct makes it easy to pass the same arguments on to another function if that is required.

If you REALLY want to do the 20 argument functions and have more than one, you might want to make a convention for the declaration and calling of the functions where you put each argument on its own line in the source file. It helps with the argument counting and other validation if the parameter list is clear. It would also help to have a logical organization for the order that the parameters appear.

sample of layout, but I still don't recommend it:

void Totaler(float *totfedtax, 
    float *totssitax, 
    float *totstatetax,
    float *totrate, 
    float *totreg,
    float *totovt, 
    float *totgross,
    float *totpay,
    float *totdeferred, 
    float gross, 
    float federaltax, 
    float statetax,
    float ssitax,
    float hours, 
    float payrate,
    float deferred,
    float reghrs,
    float ovthrs,
    float netpay);

// then the call would look something like:
Totaler(gross, 
    federaltax,
    statetax,
    ssitax,
    hours, 
    payrate, 
    deferred,
    reghrs, 
    ovthrs, 
    netpay, 
    &totrate, 
    &totreg, 
    &totgross,
    &totfedtax, 
    &totssitax, 
    &totnet,
    &totovt, 
    &totstatetax, 
    &totdeferred, 
    &totpay);

Wait...now look at that...(those were copied from your original post and re-formatted).

There are 20 arguments to the call, but only 19 on the declare?

And the order doesn't even pretend to match?

And if you do the struct thing, the call to Totaller could take 2 structs, one for the totals and one for the new data to add to the totals.

Sample struct, but you can add or remove fields as appropriate

struct Payinfo {
    float gross;
    float federaltax;
    float statetax;
    float ssitax;
    float hours;
    float payrate;
    float deferred;
    float reghrs;
    float ovthrs;
    float netpay;
}

And if you do the struct thing, the call to Totaller could take 2 structs, one for the totals and one for the new data to add to the totals.

Sample struct, but you can add or remove fields as appropriate

struct Payinfo {
    float gross;
    float federaltax;
    float statetax;
    float ssitax;
    float hours;
    float payrate;
    float deferred;
    float reghrs;
    float ovthrs;
    float netpay;
}

I see, okay. Thanks

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.