What is wrong with my code

it is giving segmentation error , what does it means

there are many errors in your code

main error is you push a[i] to stack but you have to push i
see the modified Code

Modified Code

segmentation fault is run time error it occur when you try to access memory which is not allocated to your program

i your code you forgot to pop out the remaining elemets from the stack.

this is my corrected code , can you tell what is wrong with it now

please reply fast …

MOdified Code

you have to check whether s is empty or not first

correct
if (s.empty() || a[i] >= a[s.top()]) {

wrong
if(a[i]>=a[s.top()] || s.empty()){

ohh , thanks i got it now