Issues passing by address/reference
<p>Below is the main file to my program. I am having issues specifically on line 44. When I enter in a number for deferred earnings(defr) the program works properly.  However, if I leave deferred earnings(defr) as "0" my output is way off of what it should be.  Can anybody point me in the right direction in what to do? I don't believe that the included files would be of any issue. They are separate functions.  Thank you!</p>

<p>EDIT: Apologies, line 44 is: <code>InputEmployeeData(r.firstname,r.lastname,&amp;r.payrate,&amp;r.defr,&amp;r.hours);//Call 3.3</code></p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include "EmployeeRecord.h"
#include "CalcTaxes.o"
#define ADDR(var) &amp;var
#define REPORTCOLUMNHEADINGS1 "Employee           Pay    Reg Hrs  Gross    Fed     SSI     Net\n"
#define REPORTCOLUMNHEADINGS2 "Name               Rate   OVT Hrs  Pay      State   Defr    Pay\n"
#define BARS                  "========           =====  =======  =======  ======  ======  =======\n\n"  
#define REPORTCOLUMN1         "%s, %s\t%8.2f%8.2f%10.2f%8.2f%8.2f%9.2f\n"
#define REPORTCOLUMN2         "%32.2f%18.2f%8.2f\n\n"

void PrintReportHeadings(FILE * ReportFile); //3.1
void InputEmployeeData(char * lastname,char * firstname,float * hours,float * payrate,float * defr); //3.3
extern void CalculateTaxes(float gross, float defr, float *ft, float *st, float *ssit); //3.5
void PrintSummaryReport(float pr,float reg,float ovt,float gp,float fedt,float stt,float sst,float def,float np,float avgpr,float avgreg,float avgovt, 
                        float avggp,float avgfedt,float avgstt,float avgsst,float avgdef,float avgnp,FILE * ReportFile); //3.7

int main()
    {
     EmployeeRecord r; // Call Employee Record Definitions
     float reghours,ovthours; 
     float ft,st,ssit;
     float pr,reg,ovt,gp,fedt,stt,sst,def,np;
     float avgpr,avgreg,avgovt,avggp,avgfedt,avgstt,avgsst,avgdef,avgnp;
     char answer;
     int empCount;
     FILE * ReportFile;

     PrintReportHeadings(ReportFile); //Call 3.1    

     empCount = 0;// count initializations  
     pr = reg = ovt = gp = fedt = stt = def = sst = np = 0;
     do
       {
         InputEmployeeData(r.firstname,r.lastname,&amp;r.payrate,&amp;r.defr,&amp;r.hours);//Call 3.3

         if (r.hours &gt; 40)
           {
             reghours = 40;
             ovthours = r.hours - 40;
           }
         else {
             reghours = r.hours;
             ovthours = 0;
         }      
          r.gross = (reghours * r.payrate)+(ovthours * r.payrate * 1.5);
          CalculateTaxes(r.gross,r.defr,&amp;ft,&amp;st,&amp;ssit);//Call 3.5 CalculateTaxes 
          r.net = r.gross - ft - st - ssit;
          printf(REPORTCOLUMNHEADINGS1);
          printf(REPORTCOLUMNHEADINGS2);
          printf(BARS); 
          printf(REPORTCOLUMN1,r.lastname,r.firstname,r.payrate,reghours,r.gross,ft,ssit,r.net); 
          printf(REPORTCOLUMN2,ovthours,st,r.defr);   
              ReportFile = fopen("report.txt", "a");
              fprintf(ReportFile,REPORTCOLUMN1,r.lastname,r.firstname,r.payrate,reghours,r.gross,ft,ssit,r.net); 
              fprintf(ReportFile,REPORTCOLUMN2,ovthours,st,r.defr); 
              fclose(ReportFile);
          empCount = empCount + 1;
          pr = pr + r.payrate;
          fedt = fedt + ft;
            if (r.hours &gt; 40)
              {
                   reghours = 40;
                   ovthours = r.hours - 40;
              }
              else {
                   reghours = r.hours;
                   ovthours = 0;
              }
          reg = reg + reghours;    
          ovt = ovt + ovthours;
          gp = gp + r.gross;
          stt = stt + st;
          sst = sst + ssit;
          np = np + r.net;
          def = def + r.defr;
          avgpr = pr / empCount;
          avgfedt = fedt / empCount;
          avgreg = reg / empCount;
          avgovt = ovt / empCount;
          avggp = gp / empCount;
          avgstt = stt / empCount;
          avgsst = sst / empCount;
          avgnp = np / empCount;
          avgdef = def / empCount;

              fflush(stdin);
              printf(" Repeat (Y/N)? : ");
              scanf("%c",ADDR(answer)); 
        } while (answer == 'Y' || answer == 'y');
            printf("\n"); // print one line for spacing 
       printf("\nTotals %17.2f%8.2f%10.2f%8.2f%8.2f%9.2f\n",pr,reg,gp,fedt,sst,np); 
       printf("%32.2f%18.2f%8.2f\n",ovt,stt,def); 
       printf("\nAverages %15.2f%8.2f%10.2f%8.2f%8.2f%9.2f\n",avgpr,avgreg,avggp,avgfedt,avgstt,avgnp); 
       printf("%32.2f%18.2f%8.2f\n",avgovt,avgsst,avgdef);

       PrintSummaryReport(pr,reg,ovt,gp,fedt,stt,sst,def,np,avgpr,avgreg,avgovt,
                        avggp,avgfedt,avgstt,avgsst,avgdef,avgnp,ReportFile); //Call 3.7       

        fflush(stdin);
        getchar();
        return 0;
}

void PrintReportHeadings(FILE * ReportFile) //3.1
{
    ReportFile = fopen("report.txt", "w");
    fprintf(ReportFile,REPORTCOLUMNHEADINGS1);
    fprintf(ReportFile,REPORTCOLUMNHEADINGS2);
    fprintf(ReportFile,BARS);
    fclose(ReportFile);
}

void InputEmployeeData(char * lastname,char * firstname, float * hours, float * payrate, float * defr) //3.3
{
     printf("Enter employee's name: ");  // input section
     scanf("%s%s",firstname,lastname);
     printf("Enter hourly pay rate: ");
     scanf("%f",payrate);
     printf("Enter deferred amount: ");
     scanf("%f",defr);
     printf("Enter hours worked this pay period: ");
     scanf("%f",hours);
}

void PrintSummaryReport(float pr,float reg,float ovt,float gp,float fedt,float stt,float sst,float def,float np,float avgpr,float avgreg,float avgovt, 
                        float avggp,float avgfedt,float avgstt,float avgsst,float avgdef,float avgnp,FILE * ReportFile) //3.7
{
     ReportFile = fopen("report.txt", "a");
     fprintf(ReportFile,"\nTotals %17.2f%8.2f%10.2f%8.2f%8.2f%9.2f\n",pr,reg,gp,fedt,sst,np); 
     fprintf(ReportFile,"%32.2f%18.2f%8.2f\n",ovt,stt,def); 
     fprintf(ReportFile,"\nAverages %15.2f%8.2f%10.2f%8.2f%8.2f%9.2f\n",avgpr,avgreg,avggp,avgfedt,avgsst,avgnp); 
     fprintf(ReportFile,"%32.2f%18.2f%8.2f\n",avgovt,avgstt,avgdef);
     fclose(ReportFile);
}
</code></pre>
