So I'm having a bit of trouble with one of my programs.
Some of you might be familiar with this one, ha.
I want to keep the code as close to this as I can.
I'm trying to combine some files into one program but it keeps giving me this compiler error.
50 - invalid use of undefined type `struct employee'
45 - forward declaration of `struct employee'
and it does this twice.
Any idea where I'm going wrong?
Code:
#include <stdio.h>
#include <stdlib.h>
#define MAXNAME 40
#define PHONEFIX 4
#define PHONEEND 5
int main()
{
void printEmployees(struct employee table[], int n);
int i, n;
struct phonenum
{
char phoneArea[PHONEFIX]; //Phone area code.
char phoneMiddle[PHONEFIX]; //Middle 3 of phone #.
char phoneLast[PHONEEND]; //Last 4 of phone #.
};
struct employee
{
long number; //Employee number.
char name[MAXNAME]; //Employee Name.
struct phonenum phone; //Employee phone #;
int age; //Employee Age.
};
struct employee emptable[] = //Listing of Employees.
{
{859630, "Windsor, Elizabeth ", "800", "467", "8336",
};
printEmployees(emptable, sizeof(emptable)/sizeof(emptable[0]));
system("pause");
}
(45)void printEmployees(struct employee table[], int n)
{
int i;
for(i = 0; i < n; i++)
(50) printf("%s\n", table[i].name);
}