-
help
could anyone tell me where i am messing this up please?
Code:
struct empinfo{
char name[21];
char name1[21];
int hours;
float payrate;
};
Code:
#include <c:\Documents and Settings\Pat\Desktop\Copy of New Folder (3)\empinfo.h\m15.cpp\struct15.cpp>
extern void getempdata(struct empinfo emp1[], int &count1,int MAX1);
int main()
{ const int MAX =25;
struct empinfo emps[MAX];
int count;
getempdata(emps,count,MAX);
return 0;
}
Code:
#include <iostream>
#include <c:\Documents and Settings\Pat\Desktop\New Folder (3)\m15.cpp\m15.cpp\struct15.cpp>
using namespace std;
void getempdata(struct empinfo emp1[], int &count1, int MAX)
{
char ans,ret;
count1 =0;
while (((ans=='Y')||(ans =='y'))&&(count1<MAX))
{
cout << "tnput last name:";
cin.getline (emp1[count1].name,21);
cout << "input first name:";
cin.getline (emp1[count1].name1,21);
cout << "input hours:";
cin >> emp1[count1].hours;
cout << "input payrate:";
cin >> emp1[count1].payrate;
count1++;
cout << "input another - Y or N:";
cin >> ans;
cin.get(ret);
}
return;
}
errors
>------ Build started: Project: main15.cpp, Configuration: Debug Win32 ------
1>Compiling...
1>main15.cpp
1>Linking...
1>main15.obj : error LNK2019: unresolved external symbol "void __cdecl getempdata(struct empinfo * const,int &,int)" (?getempdata@@YAXQAUempinfo@@AAHH@Z) referenced in function _main
1>C:\Documents and Settings\Pat\Desktop\Copy of New Folder (3)\main15.cpp\Debug\main15.cpp.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\Pat\Desktop\Copy of New Folder (3)\main15.cpp\main15.cpp\Debug\BuildLog.htm"
1>main15.cpp - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
-
"Help" is not a thread title.
http://cboard.cprogramming.com/showthread.php?t=85954
http://cboard.cprogramming.com/showthread.php?t=85970
http://cboard.cprogramming.com/showthread.php?t=86104
Why are you #including code inside code?
Where is your struct actually declared, other than in your post?
As a single file, does this work?
Code:
#include <iostream>
using namespace std;
// This would go into empinfo.h
struct empinfo{
char name[21];
char name1[21];
int hours;
float payrate;
};
extern void getempdata(struct empinfo emp1[], int &count1,int MAX1);
// This would go into empinfo.cpp
void getempdata(struct empinfo emp1[], int &count1, int MAX)
{
char ans,ret;
count1 =0;
while (((ans=='Y')||(ans =='y'))&&(count1<MAX))
{
cout << "tnput last name:";
cin.getline (emp1[count1].name,21);
cout << "input first name:";
cin.getline (emp1[count1].name1,21);
cout << "input hours:";
cin >> emp1[count1].hours;
cout << "input payrate:";
cin >> emp1[count1].payrate;
count1++;
cout << "input another - Y or N:";
cin >> ans;
cin.get(ret);
}
return;
}
// This would go into main.cpp
int main()
{ const int MAX =25;
struct empinfo emps[MAX];
int count;
getempdata(emps,count,MAX);
return 0;
}
As 3 files, it would be like this
Code:
// This would go into empinfo.h
struct empinfo{
char name[21];
char name1[21];
int hours;
float payrate;
};
extern void getempdata(struct empinfo emp1[], int &count1,int MAX1);
Code:
#include <iostream>
#include "empinfo.h"
using namespace std;
// This would go into empinfo.cpp
void getempdata(struct empinfo emp1[], int &count1, int MAX)
{
char ans,ret;
count1 =0;
while (((ans=='Y')||(ans =='y'))&&(count1<MAX))
{
cout << "tnput last name:";
cin.getline (emp1[count1].name,21);
cout << "input first name:";
cin.getline (emp1[count1].name1,21);
cout << "input hours:";
cin >> emp1[count1].hours;
cout << "input payrate:";
cin >> emp1[count1].payrate;
count1++;
cout << "input another - Y or N:";
cin >> ans;
cin.get(ret);
}
return;
}
Code:
#include <iostream>
#include "empinfo.h"
using namespace std;
// This would go into main.cpp
int main()
{ const int MAX =25;
struct empinfo emps[MAX];
int count;
getempdata(emps,count,MAX);
return 0;
}
Your project should contain just main.cpp and empinfo.cpp