I am writing a program with in which I have to create a list of employees and work with the information in it. In the writeToFile I write the info. to a .txt file. In the newList I should create a new list, which will contain employees which match certain criteria. However, when I intiliaze *newListHead pointer I get initialization of 'newEmployeeList *' {aka 'struct newEmployeeList *'} from incompatible pointer type 'List *' {aka 'struct List *'} [-Wincompatible-pointer-types]| error. What am I doing wrong since I did the same thing for the head pointer?
typedef struct employee {
char name[20];
double salary;
char gender[10];
} employee;
typedef struct List {
employee info;
struct List *next;
} List;
typedef struct newEmployeeList {
employee info;
struct newEmployeeList *next;
} newEmployeeList;
List *create_new_node() {
List *new_node = NULL;
new_node = (List*)malloc(sizeof(List));
new_node->next = NULL;
return new_node;
};
int main()
{
List *head = create_new_node();
writeToFile("test.txt", head);
newEmployeeList *newListHead = create_new_node();
newList(head, newListHead);
return 0;
}
ListandnewEmployeeListwhich are exactly equivalent aside from the name?ListandnewEmployeeListare two different types. You should only have one type for both. Just get rid of thenewEmployeeListtype and useListin its place.