Slightly fixed the push and pop methods.
In push(), the top is incremented first and then a value is assigned.
In pop, the top is simply decremented. The underflow check condition is good.
Now coming to the main part, the search function is kind of unnecessary in a stack. I don't know why your teacher is encouraging you to even try it.
I mean what's the point really?
Suppose you have the required key at "n" index, you have to pop each and every element out of the stack upto "n" element, in order for a match.
So you are doing n pops basically. If the nth value is big i.e 100 or more, then you've to do 100 pops or more to find the key. Its simple linear search and is inefficient.
Stacks are never designed for any searching purpose.
If you want efficient search algorithm, try
binary search. Also ask your teacher why they are encouraging to search a key from a stack.
You can use stacks for more practical purposes like reversing a string. Notice what happens when you pop elements out of a stack. Aren't the order reversed?