Why segmentation fault
Check your code from line 38 to 43.
You are performing s.top() without checking if s is empty or not. WHEN stack is empty and you perform s.top(), then this will cause a segmentation fault.
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.