![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Posts: 8
Rep Power: 0
![]() |
reading records from a file
Can someone help me to figure his out. I have to read in a file that contains employee names, numbers, payrates, and hours. Then I have to calculate the gross andsend everything to an output file. I keep getting this error message
"employee.cpp" 69 lines, 1471 characters $ c++ employee.cpp Undefined first referenced symbol in file putdata(char *, int, float) /var/tmp/cckpUsol.o getdata(char *, int, float, int) /var/tmp/cckpUsol.o ld: fatal: Symbol referencing errors. No output written to a.out collect2: ld returned 1 exit status $ this is my program #include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
const int MAXNAME = 20;
const int NUMRECS = 12;
int i=0;
struct employees
{
int number, hours;
float rate, gross;
char name[MAXNAME];
}employee;
int employees[NUMRECS];
void getdata(char [], int, float, int);
void processdata(float, int);
void putdata(char [], int, float);
ifstream HopeData;
ofstream MikeData;
void main()
{
HopeData.open("personel.dat");
MikeData.open("putdata");
if(HopeData.fail())
{
cout << "\n\nFile not successfully opened\n\n";
}
cout << "\n\nFile successfully opened\n\n";
getdata(employee.name, employee.number, employee.rate, employee.hours);
putdata(employee.name, employee.number, employee.gross);
HopeData.close();
MikeData.close();
}
void getdata(int name[], int number, float rate, int hours)
{
while(i < NUMRECS)
{
HopeData >> employee.name >> employee.number >> employee.rate >> employee.hours;
}
processdata(employee.rate, employee.hours);
}
void processdata(float rate, int hours)
{
employee.gross = employee.rate * employee.hours;
}
void putdata(char name, int number, float gross)
{
cout << "\n\n Payroll Report" << endl;
cout << " Name Number Gross Pay" << endl;
cout << setiosflags(ios::showpoint);
cout << setiosflags(ios::fixed);
cout << setprecision(2);
cout << setw(15) << employee.name << setw(5) << "\t" << employee.number << setw(7) << "\t$" << employee.gross << endl;
}And this is a sample of my file that i'm reading Simmons 2242 8.00 40 Alexander 8343 5.98 40 Jenkins 6234 4.65 23 Gardiner 1009 9.34 40 Ward 2289 3.57 40 Simien 5342 3.09 40 Smith 7344 7.00 40 Fresch 2942 6.50 40 Donato 5034 8.09 40 Glasper 1276 8.32 40 Marsh 8234 7.98 40 Fontenot 2454 6.95 40 Johnson 1523 6.98 40 Deville 2212 1.45 40 Clay 1912 2.89 40 |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Feb 2005
Posts: 64
Rep Power: 4
![]() |
your function prototypes do not match your function definitions
getdata prototype (char[], int , float, int) getdata definition (int[], int, float, int) similar for putdata, in the prototype your first argument is a char[] , in the definition your first argument is just a char |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Feb 2005
Posts: 8
Rep Power: 0
![]() |
thanx so much
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|