Hi,
could you please help me with my cose.
I don't understand what is wrongvwith the:
"append (head, read_data());"
the error:
incompatible type for argument 2 of ‘append’
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
enum status{marrid=1,devorse,single};
enum department{RandD=1,marketing,testing};
typedef struct employee
{
char f_name[10];
char l_name[10];
int ID ;
enum status Fstatus;
enum department Wdepartment;
int Age;
int Sallery;
int Seniority;
}employee;
struct node
{
employee emp;
struct node* next;
};
typedef employee* EmployeePtr;
const MAX = 3;
int read_data()
{
EmployeePtr p;
printf("Enter your first name:\n ");
//flushall();
gets(p->f_name);
printf("Enter your last name:\n ");
//flushall();
gets(p->l_name);
printf("Enter ID:\n ");
//flushall();
scanf ("%d",&p->ID);
printf("Enter Fstatus(marrid=1,devorse=2,single=3):\n ");
//flushall();
scanf ("%d",&p->Fstatus);
printf("Enter Wdepartment(RandD=1,marketing=2,testing=3):\n ");
//flushall();
scanf ("%d",&p->Wdepartment);
printf("Enter Age: \n");
//flushall();
scanf ("%d",&p->Age);
printf("Enter Sallery:\n ");
//flushall();
scanf ("%d",&p->Sallery);
printf("Enter Seniority: \n");
//flushall();
scanf ("%d",&p->Seniority);
return p;
}
void append (struct node* head, employee emp) // add
{
struct node* new_last;
struct node* n_last = new_last;// node; //n_last = new last
static struct node* last;
n_last->emp = emp;
n_last->next = NULL;
if (head == NULL)
{
head = n_last;
}
else
{
last->next = n_last;
last = n_last;
}
}
void bulid_list (struct node* head)
{
int i;
for (i = 0; i < MAX; i++)
{
append (head, read_data());
}
}
void read_2_file (struct node* head, FILE *f)
{
f = fopen ("employee.txt", "wt");
struct node* temp = head;
while (temp != NULL)
{
fprintf (f, "%s %s %8.2f\n", temp->emp.f_name, temp->emp.l_name,temp->emp.ID);
temp = temp->next;
}
fclose(f);
}
int main()
{
return 0;
}