It failed the first two tests, it passed only the thirdtest, can you help me fix the problem? Thank you.
————————prog1_2.h——————————
typedef struct stack{
int* data;
int size;
int capacity;
} STACK;
STACK* MakeStack(int initialCapacity);
void Push(STACK *stackPtr,int data);
int Pop(STACK *stackPtr);
void Grow(STACK *stackPtr);
————————prog1_2.c——————————
#include “prog1_2.h”
#include <stdio.h>
#include <malloc.h>
STACK* MakeStack(int initialCapacity) {
STACK *s = (STACK *)malloc(sizeof(STACK));
s->capacity = initialCapacity;
s->size = 0;
s->data = (int*)malloc(sizeof(int)*initialCapacity);
return s;
}
void Push(STACK *stackPtr, int data) {
if(stackPtr->size < stackPtr->capacity){
stackPtr->data[stackPtr->size++] = data;
}
}
int Pop(STACK *stackPtr) {
if(stackPtr->size == 0) {
return -1;
} else {
returnstackPtr->data[–(stackPtr->size)];
}
}
void Grow(STACK *stackPtr) {
int i;
stackPtr->capacity *= 2;
int *arr = (int*)malloc(sizeof(int)*stackPtr->capacity);
for(i = 0;
PayPal Gateway not configured
PayPal Gateway not configured