logo

Crowdly

Adott: typedef struct {     int capacity;     int top;     int *elements...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Adott:

typedef struct {

    int capacity;

    int top;

    int *elements;

} Stack;

és az alábbi függvény:

void createStack(int capacity, Stack *stack) {

    stack->capacity = capacity;

    stack->top = -1;

    stack->elements = (int*)calloc(stack->capacity, sizeof(int));

    if (!stack->elements) {

        printf("MEMORY_ALLOCATION_ERROR_MESSAGE");

        exit(-3);

    }

}

A fenti függvény helyesen inicializálja a verem struktúrát, és biztonságosan ellenőrzi a memóriafoglalást.

100%
0%
More questions like this

Want instant access to all verified answers on moodle.ms.sapientia.ro?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome