Reputation:
I have to following C code:
a.b[(c+d(e,f,g)**i)]->j<-k
Now I have to add code to make it compile.
Most of that isn't a problem but what really irritates me is the d(e,f,g)**i
part. **i
as I understand is a pointer to a pointer, but I don't know how to handle it directly after a function call.
Upvotes: 0
Views: 114
Reputation: 81926
Well this is relatively awful. Let's work from the inside out and remove things as we deal with them:
d is a function with 3 parameters. Let's assume it can return an int, and if it can't we'll deal with that later:
int e, f, g;
int d(int, int, int);
d(e,f,g) * *i
will be fine if i is a pointer to an int.
int *i;
c + d(e,f,g) * *i
will be fine if c is also an int.
int c;
So now we have the inside of the brackets completed. We also wanted that to be an integer so that it could work as an array notation. So we're good there. Let's rewrite the question without some of the stuff that we've resolved.
a.b[<some integer>]->j < -k
We can do the right side pretty easily.
int k;
This part is difficult to put into words, but I'm just walking the types. b
is a double star because it's using array brackets followed by an -> sign.
struct {
struct {
int j;
} **b;
} a;
#include <stdlib.h>
int main() {
int e, f, g;
int d(int e, int f, int g);
int *i;
int c;
int k;
struct {
struct {
int j;
} **b;
} a;
a.b[(c+d(e,f,g)**i)]->j<-k;
}
Upvotes: 0
Reputation: 410
Simple Enough
d(e,f,g) * *i // where d(e,f,g) is a function which should return a value and
*i is a pointer value
Eg if function d(e,f,g) returns 10 and if *i=5 then then output will be 10*5 = 50
Upvotes: 0
Reputation: 64682
Just break it down:
d(e,f,g)**i
FunctionCall d with params e,f,g
Multiplied by
pointer-dereferce of i
Or:
d (e,f,g) * (*i)
Func. Params Multiply value-stored-at-pointer
Upvotes: 2