- Engineering
- Computer Science
- im trying to create a function that mallocs an instance...
Question: im trying to create a function that mallocs an instance...
Question details
i'm trying to create a function that mallocs an instance and it's pointer (d). This is what I have, but I wanted to see if it was correct? it's supposed to be the basis of an array of integers.
struct intRA
{
int length;
int *d;
};
struct intRA* m_intRA(int length)
{
struct intRA *ra = malloc(sizeof(struct intRA));
ra->length = length;
ra->d = (int *)malloc(length * sizeof(int));
return ra;
}
Solution by an expert tutor
