Here is my code:
#include <stdio.h>
#define DEFAULT_CAPACITY 5
typedef struct Vector
{
int items[DEFAULT_CAPACITY];
int size;
} *VectorP;
// I am not allowed to change this struct definition.
int main()
{
VectorP *p;
p = (VectorP *) malloc(DEFAULT_CAPACITY * sizeof(VectorP));
if (p == NULL)
{
fprintf(stderr, "Memory allocation failed!\n");
exit(1);
}
//The problem is that I can't access instance of the vector this way ->
p->size = 0;
}
Searching online I found out that it is something to do with VectorP
already being a pointer, I cannot change this because my professor wants it that way. How do I solve this?