c - How do I dynamically allocate memory for the field of a struct? -
i have hash structure:
typedef struct _td_ { int size; /* size of v */ alg v; /* table elements */ } td;
and list structure:
typedef struct cellista{ void *info; struct cellista *next; } tcelulag, *tlg, **alg;
and structure info
points:
typedef struct cuv{ int frecv; char *s; }word;
somewhere inside program want allocate memory char *s
this:
tlg aux; … ((word*)(aux->info))->s=strdup(str);
and gives me warning "assigment makes pointer integer without cast...why?
you calling malloc() , you've not declared malloc() including <stdlib.h>
. default, functions assumed return int you're supposed declare function before using it.
because have not included <stdlib.h>
, assigning int char * pointer. hence warning "assigment makes pointer integer without cast".
Comments
Post a Comment