Write a program to reverse string using stack in c++

Question :- Write a program to reverse string using stack in c++

Algorithm

1) Create an empty stack using Standard Template Library(STL).
2) One by one push all characters of string to stack.
3) One by one pop all characters from stack and put
   them back to string.

Program to reverse string using stack

 

 

Output

Write a program to reverse a string using stack in c++

Suggested Reading

  1. Write a C program to reverse the words in a sentence in place
  2. Write your own trim() or squeeze() function to remove the spaces from a string
  3. Write a C program to reverse the string without using strrev() ?