Newbie problem with pointers in C.
I am trying to teach myself C (using gcc 3.3.1). I am trying
to write a simple example that does a double linked list.
I seem to be falling at the first hurdle when I try and
create the pointer. My program is:
/*look at the use of structures and pointers to produce a
double linked list*/
#include <stdio.h>
#include <malloc.h>
#include <string.h>
int main (void)
{
typedef struct
{
int time;
struct event *fptr,*bptr;
} event;
event *baseptr;
baseptr = (struct event *) malloc ( sizeof (struct event));
}
The compiler error is:
doublelinked.c:18: error invalid application of 'sizeof' to an incomplete type
doublelinked.c:18: warning assignment from incompatible pointer type
I have obviously done something daft, but would be grateful if some kind
person could tell me what is wrong.
Thanks,
Chris
|