Course Solutions Uncategorized (Solved) : Failed First Two Tests Passed Third Test Help Fix Problem Thank Prog12h Typedef Struct St Q26644051 . . . .

(Solved) : Failed First Two Tests Passed Third Test Help Fix Problem Thank Prog12h Typedef Struct St Q26644051 . . . .

 

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;

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post