how to print a stack in cpp code example Example: print stack c++ while(!myStack.empty()) { cout << myStack.top() << " "; myStack.pop(); }