Hi,
I am write code about stack[pop,push,overflow,underflow]
but i think i have Mistake in underflow and overflow ..
and how i can Enter any thing in my array ..
like if i want to enter [$] or[xxxxx] whatever not only int
if you can correct in same code >>

#include<iostream.h>
void main()
{
	int x;
int a[1000];
	int i;
	cout<<"Enter your size:";
cin>>x;
cout<<"Enter your element\n";
for(i=0;i<x;i++){
cout<<"Enter your num"<<i<<":";
cin>>a[i];
}
if(i==x)
cout<<"array is overflow\n";
else 
cout<<"Under flow\n";
for(i=x-1;i>=0;i--)
cout<<"The element pop from index "<<i<<"::"<<a[i]<<"\n";


}
//}

You should use a vector<string> or vector<char> if you want to store things besides ints. Better yet, why not use a stack<char> which provides all of the functions you are looking to implement already?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.