•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 423,873 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,971 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 2011 | Replies: 2
![]() |
•
•
Join Date: Oct 2004
Posts: 43
Reputation:
Rep Power: 5
Solved Threads: 0
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
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
"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
My compiler shows something similar after fixing this oddity.
So the linker says it can't find these functions. Let's look at what we have. Sure enough. The prototyped functions don't exist.
If employees is the destination array, don't you think you should reference it somewhere?
employee.grossddd = employee.rate * employee.hours;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) { // ... }
If employees is the destination array, don't you think you should reference it somewhere?
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- reading records from a .dbf file (Visual Basic 4 / 5 / 6)
- Reading numbers from a text file (Java)
- Trouble Reading Records (C++)
Other Threads in the C++ Forum
- Previous Thread: header file/ classes
- Next Thread: Exception Handling



Linear Mode