This is part of a study guide at the moment and while I realize its not very difficult, I can’t understand what its asking for.
Write a Function:
struct *grump(int i, int j)
which returns a pointer to a “struct grump” holding the values i, j in its fields a,b
So Im given
struct grump
{
int a;
int b;
};
I’m just confused as to what its asking for
It’s asking you to allocate a
struct grumpthat will hold the valuesiandj, something like:Note: we check if
g != NULLto make suremalloc()succeeded before usinggrumpif not the function will returnNULL. Of course at some point you will need tofree()that memory, I’m sure your study guide will mention it soon.