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.grossddd = 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

Recommended Answers

All 2 Replies

My compiler shows something similar after fixing this oddity.

employee.grossddd = employee.rate * employee.hours;

So the linker says it can't find these functions. Let's look at what we have.

void getdata(char [], int, float, int);
void putdata(char [], int, float);
// ...
void getdata(int name[], int number, float rate, int hours)
{
   // ...
}
void putdata(char name, int number, float gross)
{
   // ...
}

Sure enough. The prototyped functions don't exist.

If employees is the destination array, don't you think you should reference it somewhere?

Might it be that "employees" is ambiguous? It's both the name of the an array of integers and it's also a type that you've defined. (struct employees).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.