Why my code is not working

@kundankumarsports2 if you are treating string as a character array, you have to use the correct method for declaration as well. https://ide.codingblocks.com/s/215206 see line 53, this is how you make a character array. You can assign pointers only to some address, not any random literals.

@kundankumarsports2 by the way you can just use the inbuilt stack function, you dont have to reinvent the wheel everytime. It has all the functionalities like push(), pop(), top(), empty(), you can use it by including the “stack” header file. Syntax is as follows
stack s1;
s1.push(8);
cout << s1.top();
s1.pop();
if (s1.empty()) {cout << “\nstack is empty”;}

output will be
8
stack is empty

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.