How do you print each element from a stack?

Simple question I just need to know how to print each individual element from a stack
I didn't see any answers there that work for me.. I need to write a function called print in the implementation file that prints the elements in the stack without popping them. I tried this but it didn't work
1
2
3
4
5
6
7
8
9
10
void stack::print ()
{
	int x;
	if(!empty())
	{
		for(x = 0; x < top; x++);
		cout << data[x] << " ";
	}
	if(empty())
	cout << "Empty!" << endl;
You might want to remove the semi-colon on line 6.
Oh yeah that helped haha thanks!
Topic archived. No new replies allowed.