I have a simple structure.
struct grades
{
int lowest;
int highest;
};
Then I am to create a function that returns a pointer which initializes the structure.
struct *grades setGrades(int low, int high)
{
struct *ptr = malloc(sizeof(struct grades));
ptr->lowest = low;
ptr->highest = high;
return ptr;
}
Now I am supposed to make a function with definition struct **grades random(int size);
I am supposed to allocate space for an array of pointers to grade structures with the number of elements equal to size. When the array of pointers is created, I want to set each pointer in the array to a newly created data structure that has the low variable equal to 10 and high variable equal to 100 and then return pointer.
I am really lost at this point as I looked up double pointers to structures online but did not find any examples that can help me clear my understanding. I was wondering if someone can perhaps explain me how double pointers to structures work it would give me a Great start in the right directions.
struct *gradesandstruct *ptr???createGradeSetbecause you are returning a new struct each time that is called.struct grades*andstruct grades* ptr, no? ;)doublefor a "double precision floating point number" (so like float, but "bigger"). You might find more relevant reading with "pointer to a pointer". If you think of a pointer as being a data type like any other, just realize that*ppwill give you a pointer if pp is a pointer-to-pointer.