it seems like there\'s a problem with my code but i can\'t figure it out.
if i compare empcode to code from file nothing happens.
here\'s the code: (sorry little messy.)
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <fstream.h>
#include <stdio.h>
void newemp();
void search();
void dtr();
void quit();
int main(){
int choice;
clrscr();
cout<<"[1] Enter a new Eployee\n";
cout<<"[2] Search\n";
cout<<"[3] Daily time record\n";
cout<<"[4] Quit\n";
cin>>choice;
switch (choice){
case 1:
newemp();
break;
case 2:
void search();
break;
case 3:
dtr();
break;
case 4:
quit();
break;
}
getch();
return 0;
}
void newemp(){
clrscr();
char name[100], code[100];
int level;
ofstream emp("newemp.txt", ios::app);
cout <<"Enter Employee Name: \n";
cin>>name;
cout<<"Enter Employee Code: \n";
cin>>code;
cout<<"Enter Employee Salary Level: \n";
cin>>level;
emp << name <<"," << code <<"," << level<<endl;
emp.close();
cout<<"Employee Recorded!";
main();
}
double totalregW =0, totalotW=0, totalHolW=0, totalUnderW=0, totalLateW=0, pay, gross, gross1, gross2, sss, net, tax, late, under,sssR, taxR;
char holiday,y, empcode[50];
char days[6][10] = {"","Monday","Tuesday","Wednesday","Thursday","Friday"};
void dtr()
{
system("cls");
system("TITLE Payroll");
system("COLOR 0F");
Computation CompClass;
char in[10],out[10],ot_in[10],ot_out[10], record[100],name[100], code [100];
double h_in, m_in, h_out, m_out, OTh_in, OTm_in, OTh_out,OTm_out,totalH, totalM, total, totalOT,totalOTH, totalOTM,totalHoliday, totaldeducL, totaldeducU;
int level;
do{
system("cls");
clrscr();
[color="#FF0000"][font="Arial Black"]cout<<"Enter Employee Code: \n";
cin>>empcode;
ifstream emp("newemp.txt");
while ( !emp.eof() ){
emp>>record;
// cout<<record;
char *rec =strtok(record,",");
strcpy (name,rec);
rec = strtok(NULL, ",");
strcpy (code, rec);
rec = strtok(NULL, ",");
level = atoi(rec);
if ((empcode == code)==0){
cout<<name<<endl;
cout<<code<<endl;
if (level == 1){
pay = 350/8.0;
sssR = .01;
taxR = .10;
}else if (level == 2){
pay = 450/8.0;
sssR = .015;
taxR = .10;
}else if (level == 3){
pay = 550/8.0;
sssR = .02;
taxR = .10;
}
break;
}else {
cout<<"No record!";
main();
}
}
[/font][/color]
here's the info from notepad
DelaCruz_Juan,A02-112,3
Smith_John,A03-113,2
Please give Feedbacks.
Thanks!

New Topic/Question
Reply



MultiQuote




|