reverseStack wrong output

I am not getting the correct output for reversing a stack.

Ans: https://ide.codingblocks.com/#/s/32805

Replace s1 by &s1 in line 5.
This solves it correctly. You just need to pass it by reference. The logic is correct.

1 Like