Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,104 questions

40,777 answers

573 users

How to use stack with push, empty, pop and top in C++

1 Answer

0 votes
#include <iostream>  
#include <stack> 

using std::stack;
using std::cout;
using std::endl;

int main()
{
	stack<char> stck;

	stck.push('a');
	stck.push('b');
	stck.push('c');
	stck.push('d');
	stck.push('e');

	while (!stck.empty()) {
		cout << stck.top() << endl;
		stck.pop();
	}

	return 0;
}

/*
run:

e
d
c
b
a

*/

 





answered Apr 24, 2018 by avibootz

Related questions

1 answer 18 views
1 answer 16 views
1 answer 21 views
...