This part of the code keeps on giving me segmentation fault. It's a stack structure. For testing I just made a global variable top to keep track of the stack. There's no problem in the logic when I implement it in c++ so I'm not sure why there's an error. Thanks.
struct v
{
  char *value;
  int ibase;
  int obase;
  struct v* next;
};
struct v* top = NULL;
void push(char* val, int ibas, int obas)
{
  struct v* newstackptr;
  newstackptr->next = top;
  newstackptr->value= val;
  newstackptr->ibase= ibas;
  newstackptr->obase= obas;
  top = newstackptr;
}
int main(){
char* value="111";
push(value,2,8);
return 0;
}
 
    