hello,
can someone kindly correct the errors in my c program.i am unable to get the errors.
my program is:
doc.c(starts from line 22):
Code:
struct element *new_doc( int i, const char *name)
{
struct element *e = malloc( sizeof( struct element) );
if( e == NULL)
{
yyerror( "new_node: malloc failed");
exit(1);
}
e->name = name;
e->type = i;
e->next = NULL;
return e;
}
void append_doc(struct element *e)
{
e->name = name;
e->type = i;
e->next = head;
head = e;
}
doc.h:
Code:
typedef struct element
{
char *name;
int type;
struct element *next;
}Documen;
struct element *head = NULL;
void append_doc( struct element *e);
struct element *new_doc( int i,const char *name);
errors:
doc.c: In function `new_doc':
doc.c:30: warning: assignment discards qualifiers from pointer target type
doc.c: In function `append_doc':
doc.c:38: `name' undeclared (first use in this function)
doc.c:38: (Each undeclared identifier is reported only once
doc.c:38: for each function it appears in.)
doc.c:39: `i' undeclared (first use in this function)
Regards,
Akshara