Question: how can I implement the pop function for a stack in C, that takes as a parameter the address of the variable that is on
how can I implement the pop function for a stack in C, that takes as a parameter the address of the variable that is on top of the stack. I am new to c and have no experience as to how pointers work.
int main(){
char c; int value;
printf("Add value to stack "); scanf("%d", &value); push(value);
pop(&value);
}
push and pop function written in a different class called stack
#define MAX 10
int top = -1;
int arr[MAX];
int push(int value){
if(top == MAX-1){ printf("Overflow!!!"); //stack is full
}
top++; //increment top
arr[top] = value; // assign value to array
}
int pop(int *value){ //function to work with
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
