Signal: illegal instruction (core dumped)

Problem description:
While working on stack implement I have been facing problem " signal: illegal instruction(core dumped) " on console continuously and I think it may be because of arrow operator (->) is not working properly as I am facing this problem only when access member of stack using pointer.
so, In the end I want to know is this really a bug or some different problem .

Bug appears at this link:


you’re using the s variable before giving it a value, which is undefined behaviour. Try doing this instead:

struct stack s = {.size = 80, .top = -1};
s.arr = (int *)malloc(s.size * sizeof(int));
1 Like

Thanks for help
I have been facing this problem for quite some time wondering what to do . It’s quite a headache as I just started coding :people_hugging:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.