Accessing the Stack Top

The program should now be extended so that a function called top can be used to read the value of the top element of the stack without removing it. In main, the function can be used as follows, for example:

1
2
3
4
5
6
7
8
9
fn main()                                                                        
{                                                                                
    push(3);                                                                     
    printf("top = %d\n", top());                                                 
    push(4);                                                                     
    printf("top = %d\n", top());                                                 
    pop();                                                                       
    printf("top = %d\n", top());                                                 
}   

This should produce the following output:

1
2
3
top = 3
top = 4
top = 3