Im having trouble assigning to struct pointer in another struct pointer
The structs looks like this:
header.h
typedef struct {
int drawnlines;
char *name;
} player;
typedef struct {
char a, b;
p *mover;
p *previous;
} lastmove;
In another function Im calling another function that is supposed to change a pointer to this struct, this is also the function that gives me an warning:
program.c
#include header.h
.....
lastmove lmv;
lmv.mover=malloc(sizeof(player *));
lmv.previous=malloc(sizeof(player *));
player p;
p.drawnlines=0;
p.drawnlines=0;
strcpy(p.name, "patrik");
function(&lmv, &p);
.....
int
function(lastmove *lmv, player *p)
{
lmv->a='b';
lmv->b='a';
lmv->previous=lmv->mover;
lmv->mover=p; // warning: assignment from incompatible pointer type
}
What is wrong in my code?
UPDATE: Now the code works, was a simple mistake. The struct "lastmove" is now changed to
typedef struct {
char a, b;
player *mover;
player *previous;
} lastmove;
lmv->mover = (p *)p;,or you just mean p is 'player'?