RE: [Dev-C++] newbie function_struct_array problem
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Amit K. S. <ams...@qu...> - 2004-05-15 16:08:33
|
Give the correct type of the first parameter in following function.
void CreateEmployee (struct Emp[], int); //prototype
And you cann't pass the non const value to size of array.
thanks.
-amit
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...]On Behalf Of Dane Ensign
Sent: Saturday, May 15, 2004 3:01 AM
To: dev...@li...
Subject: [Dev-C++] newbie function_struct_array problem
Hi,
Dane here. Im having trouble getting my assignment program to compile. There
is something incorrect between the
function prototype, function call, and function headerline. But I cant
figure it out. Please can someone help me to understand
where I am going wrong?
Thank you in advance for any help you can offer me. Im sorry if Im not
supposed to include my code. SHould I attach it next time?
Here is my source:
______________________________________________
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std;
void CreateEmployee (struct [], int); //prototype
struct Emp
{
char fname[20];
char lname[20];
int age, id;
};
int qty;
int main()
{
cout << "How many Employees do you want?" << endl;
cin >> qty;
cout << "You chose to create " << qty << "employees" << endl;
Emp Employee[qty];
CreateEmployee(Employee, qty);
//DisplayTeam(qty);
cout << "Nice Job Chap! Peaceout";
system("PAUSE");
return 0;
}
void CreateEmployee(struct Employee[], int qty)
{
int b, qtyLocal;
qtyLocal = qty;
for (b = 0; b < qtyLocal; b++)
{
Employee.id = 0;
cout << "Employee Form" << endl;
cout << "First name: " << endl;
cin >> Employee[b].fname;
cout << "Last name: " << endl;
cin >> Employee[b].lname;
cout << "Age: " << endl;
cin >> Employee[b].age;
cout << "Your Employee Summary is: " << endl;
cout << Employee[b].id << endl << Employee[b].fname << endl <<
Employee[b].lname << endl << Employee[b].age;
}
}
_______________________________________________
|