Creating a stack in C, getting " error error: expected ')' before '*' token " -


usually lurk forums till can find hint me out, this...i have no idea.

so relevant pieces of code is

struct com_stack {   unsigned el_num;   struct command *st;                                            unsigned top; }; void com_push (com_stack* s,command input)  //error regarding line {   if(s->top == (s->el_num - 1))   {     s->el_num+=64;     s->stk=(command*)realloc(s->stk,sizeof(struct command)*s->el_num);   }   s->stk[s->top]=input;   s->top++; } 

i believe created struct correctly stack contain commands. el_num later assigned initial size of stack, , top element number sits @ top.

i'm not sure if i'm handling push function correctly. send in pointer of stack , single command i'm trying push in.

any or advice appreciated.

typedef struct or specify struct in functions type.

also, struct called com_stack not have member stk have member st.

struct com_stack {   unsigned el_num;   struct command *st;                                            unsigned top; };  void com_push (struct com_stack* s, struct command input)  // <-- add "struct" {   if(s->top == (s->el_num - 1))   {     s->el_num+=64;     s->st=(struct command*)realloc(s->stk,sizeof(struct command)*s->el_num); // <-- st, not stk , need "struct" here   }   s->st[s->top]=input; // <-- st, not stk   s->top++; } 

Popular posts from this blog