payroll

what's wrong with my program?.I'm just first year student u know..hehe..just a lil' help..please?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
 # include <stdio.h>
# include <conio.h>
# include <stdlib.h>
# include <string.h>


using namespace std;

float showrate (char*r);
void getrec ();
void printrec();
void getpayroll ();
void gethours ();
int getmin (char*);


	struct{	
char*name;
char*id;
char*s;	
}emp[5];
{
	char*days [5] = {"monday","tuesday","wednesday","thursday","friday"};
 
 int flag =0,x=0,2=0;

}
 char * tin = "";
 char * tout = "";
 char * ptr ="";
 float ded = 0, wkhrs = 0;
}
 
 void main (){
FILE * in;
char* employee [5],*ptr
int;
in = f open ("employee.txt "."r");
if (in == NULL)}
{
printf ("error opening file:");
getch ();
exit (0);
}
fseek (in.0, seek_set);
for(1 =0;i,<5;i++)
fgets (employee[.],31,in);
1 - 0;

while (flag<5)
{
	ptr = strt ok (employee [.],"//");
	emp [x].id = ptr;
	ptr = strtok (NULL,"//");
	emp [x].s = ptr;
	emp [x].rate = showrate (emp[x].s);
	x++,i++,flag++;
}
  
  	 getrec();
     fclose();
     getch();
 }
   
   	float showrate (char* r) {
   	int rt;
   	rt = atos (r) ;
	   switch(rt){
	   case 1: rt = 380 ; break;
	   case 2: rt = 450 ; break;
	   case 3: rt = 550 : break;
  }
return rt ;
}
void getrec (){
	char* ec;
	char* ans;
	do}
    closer ();
    print (employee.code);
    gets (ec);
     
     flag = 0; x = 0; z = 0;
     while (flag<5){
     	if 9((strcmpi (ec emp [x].id)) = 0){
     		printf (c"**********************\n");
     		printf("employee name:%s\n",emp [x].name);
     		printf("employee code:%s\n",emp [x].id);
     		printf("salary level: %s\n",emp [x].s)
     		printf("salary rate: % 0.2f\n",emp [x].rate);
     		printf("************************\n");
     		flag = s;
     	}
     }
  else{
  	flag ++; x++;z++;
    }
    if (3 < 4){
    	printf ( "no record found");
    	z = 0;
      }
      else{
      	get payroll ();
    }
    printf ("\n another?[y/n]:");
    ans = getch ();
    {
	while ans ((ans =="y"))  ((ans == "y"))
 }
 void print re() {
 		printf (c"**********************\n");
     		printf("employee name:%s\n",emp [x].name);
     		printf("employee code:%s\n",emp [x].id);
     		printf("salary level: %s\n",emp [x].s)
     		printf("salary rate: % 0.2f\n",emp [x].rate);
     		printf("************************\n");
 }
 void get payroll () {
 	float rte, reg;
 	char* cov;
 	
 	tre = empp [x] rate ;
 	gethours ();
 	reg = (wkhrs*rte)/8;
 	printrec ();
 	printf ("enter the coverage date for this payroll:");
 	gets (cov);
 	printf ("coverage date : %s\n",cov);
 	printf ("number of workhours:% 0.1 f\n",wrkhrs);
 	printf ("salary income:% 0.2 f\n ",reg);
 	printf ("************************\n");
}

   void gethours () 
   {
   	FILE * out;
   	int y = 0;
   	int ti = 0,to = 0,hrs = 0;
   	float m2 =0, m1 = 0;
   	float late = 0 , under = 0;
   	
   	out =fopen ("dtr.txt","at");
   	printf (out,"\n %s",emp[x].id);
   	while (y/s);
   }
Last edited on
At a first glance:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct{
char*name;
char*id;
char*s;	
}emp[5];
{
	char*days [5] = {"monday","tuesday","wednesday","thursday","friday"};
 
 int flag =0,x=0,2=0;

}
 char * tin = "";
 char * tout = "";
 char * ptr ="";
 float ded = 0, wkhrs = 0;
}


1. You got an anonymous struct
2. You got some brackets that shouldn't be there
First year student should learn how to indent your code properly. No one wants to look at the code that just feels out of place.

Express your function names and variable names as detailed as possible, don't use abbreviations. That help you pay you off.
if 9((strcmpi (ec emp [x].id)) = 0){

Are you right about that?

I can see numerous compiler errors. This does not even follow C++ code.
Hello mischie,

what's wrong with my program?.I'm just first year student u know..hehe..just a lil' help..please?

In answer to your to your first question, many things. Did you even compile this program to see what you get?

Line 7 is used in C++ not in C.

Lines 9 - 14 the function proto types some do not match the function definitions. Example line 11 says void printrec();, but the definition is void print re(). The space is a problem. Either remove the space or use "_" to show a space.

Other things I found like; a missing ";", a "." where a "," should be and the use of "fseek()" where it was not needed. After the the file is opened the file pointer is the beginning. there is no need to set the file pointer to the beginning.

Line 37 just says "int;". That gives an error at compile time.

That is just a start. There are more problems than I have had time to figure out.

Hope that helps for now,

Andy
Last edited on
Topic archived. No new replies allowed.