So I have been on this for quite some time now and can’t seem to find the problem, not even my teacher could find it.
So I have this header file:
#include <stdio.h>
#include <stdbool.h>
void print_list(void);
int delete_from_list(int iWordID);
wordData * create_list(int iWordID, char * cWord);
wordData * add_to_list(int iWordID, char * cWord, bool add_to_end);
wordData * search_in_list(int iWordID, struct wordData **prev);
void print_list(void);
typedef struct _wordData
{
int iWordID;
char * cWord;
struct _wordData *next;
} wordData;
And in the C file where I include this header I have this function:
wordData* create_list(int iWordID, char * cWord)
{
//printf(cWord);
printf("\n creating list with headnode as [%d] %s\n",iWordID,cWord);
wordData *ptr = (struct wordData*)malloc(sizeof(struct wordData));
if(NULL == ptr)
{
printf("\n Node creation failed \n");
return NULL;
}
ptr->iWordID = iWordID;
//char * temp = (char*)malloc(sizeof(cWord));
ptr -> cWord = cWord;
ptr->next = NULL;
head = curr = ptr;
return ptr;
}
So when I compile this error occurs:
list.h|6|error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute‘ before ‘*’ token|
I have searched quite some awnsers on this error but can’t seem to find one that helps me out.
Please help 🙂
Move the
wordDatastructdefinition to the top fo the header – it needs to come before you use it in prototypes (or you need to forward declare it).