RE: c programming help again

  • From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Thu, 25 Oct 2007 22:22:19 -0700

Well to start out with you have the structure definition in the body of
main.  You don't even have a { after main which needs to be there.  So move
the Structure definition up under the prototypes and out of main.  After you
put that there you will need an instantiation of the struct in the main
which will look like this

Struct emp myEmp;

That actually creates one of your structs in memory if you want an array of
your structs its

struct emp myEmpArray[5];

Hope that helps.



-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of John Miller
Sent: Thursday, October 25, 2007 8:03 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: c programming help again

Hi all, now, I'm supposed to make structures here. I did as best as I could
but as usual got stuck and was probably way off anyway like last week. I
promise, only 2 more after this one, if that, supposedly the next one is
real easy, so long as this one is 100% so I may not be looking for help with
that one. Thanks, code follows.

(begin code)
#include <stdio.h>

/* function prototypes */

void initData(int *clockNumberPtr,float *wagePtr,float *hoursWorkedPtr);

void getHoursWorked(int entry,int * clockNumberPtr,float *hoursWorkedPtr);

float calculateOverTime(int entry, float *wagePtr,float *hoursWorkedPtr);

float calculateGrossPay(int entry, float *wagePtr,float *hoursWorkedPtr);

void displayEntry(int entry, int *clockNumberPtr,float *wagePtr,float

int main (char *argv, int argc)

struct emp

{ /*get clock info*/

int clockNumber; /*employee number*/

float wage; /* declare wage */

float hoursWorked; /*enter hours worked*/

struct employee emp(5);

int i=0;//index for for loop


for (i=0;i<5;i++)


printf("Clock #\tWAge\thours\tOver time\tGross Pay\n");

for (i=0;i<5;i++)



} /*end get clock info*/

void initData(int *clockNumberPtr,float *wagePtr,float *hoursWorkedPtr)

{ /* declaring clock numbers and wage*/

int i; // index for for loop

emp[0].clockNumber=98401 ; /*first employee*/

emp[1].clockNumber=526488; /* second employee*/

emp[2]clockNumber=765349; /*third employee */

emp[3]clockNumber=34645; /*forth employee*/

emp[4]clockNumber=127615; /*fifth employee */

emp[0]wage=10.60; /* first employee wage

emp[1]wage=9.75; /*second employee wage

emp[2]wage=10.50; /* third employee wage */

emp[3]wage=12.25; /*employee 4 wage */

emp[4]wage=8.35; /* fifth employee wage 8/

// init hours worked to 0

for (i=0;i<5;i++)


} /*end declaring clock and wage numbers*/

void getHoursWorked(struct employee emp[])

{ /*prompt for hours*/

printf ("Enter hours worked by %d: ",clockNumberPtr[entry]);

scanf_s("%f", &(hoursWorkedPtr[entry]));

} /*end prompt for hours*/

float calculateOverTime(int entry, float *wagePtr,float *hoursWorkedPtr)

{ /* figure out overtime */

float overTimeHours=hoursWorkedPtr[entry]-40;

float overTimePay=0;

if (overTimeHours>0)


return (overTimePay);

} /* end figuring out overtime */

float calculateGrossPay(int entry, float *wagePtr,float *hoursWorkedPtr)

{ /* determine gross pay*/

float grossPay=0;

if (hoursWorkedPtr[entry]>40)




return (grossPay);

} /*end determine gross pay */

void displayEntry(int entry, int *clockNumberPtr,float *wagePtr,float

{ /*desplay results */

printf ("%d\t%0.2f\t%0.2f\t%0.2f\t%0.2f\n",






} /* end desplay output*/

(end code)

View the list's information and change your settings at

View the list's information and change your settings at 

Other related posts: